Skip to content

Instantly share code, notes, and snippets.

@loic-sharma
Created August 8, 2025 22:08
Show Gist options
  • Select an option

  • Save loic-sharma/08e54804ef78166e5d641b7cc7db9b0e to your computer and use it in GitHub Desktop.

Select an option

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
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()
}
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