Created
August 8, 2025 22:08
-
-
Save loic-sharma/08e54804ef78166e5d641b7cc7db9b0e to your computer and use it in GitHub Desktop.
iOS's three finger swipe gesture to undo/redo pops the current page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| /// This is the main view of the application, analogous to the `MaterialApp` and `HomePage` widgets in the Flutter example. | |
| struct ContentView: View { | |
| var body: some View { | |
| NavigationStack { | |
| VStack { | |
| NavigationLink { | |
| TextFieldView() | |
| } label: { | |
| Text("Show text field") | |
| .padding() | |
| .background(Color.blue) | |
| .foregroundColor(.white) | |
| .cornerRadius(10) | |
| } | |
| } | |
| } | |
| } | |
| } | |
| struct TextFieldView: View { | |
| @State private var textInput: String = "" | |
| var body: some View { | |
| VStack { | |
| Spacer() | |
| TextField("Enter text here", text: $textInput) | |
| .padding(64.0) | |
| Spacer() | |
| } | |
| } | |
| } | |
| #Preview { | |
| ContentView() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| void main() { | |
| runApp( | |
| const MaterialApp( | |
| home: HomePage(), | |
| ), | |
| ); | |
| } | |
| class HomePage extends StatelessWidget { | |
| const HomePage({super.key}); | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| body: Center( | |
| child: ElevatedButton( | |
| child: const Text('Show text field'), | |
| onPressed: () { | |
| Navigator.push(context, MaterialPageRoute(builder: (_) => const TextFieldPage())); | |
| }, | |
| ), | |
| ), | |
| ); | |
| } | |
| } | |
| class TextFieldPage extends StatelessWidget { | |
| const TextFieldPage({super.key}); | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| body: Center( | |
| child: Padding( | |
| padding: EdgeInsets.all(64.0), | |
| child: TextField(), | |
| ), | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment