tn_bottom_sheet_navigator 1.0.0
tn_bottom_sheet_navigator: ^1.0.0 copied to clipboard
Modal bottom sheets and dialogs with their own internal navigation stack, animated transitions and a height that adapts to the visible page.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:tn_bottom_sheet_navigator/tn_bottom_sheet_navigator.dart';
import 'bottom_sheet_pages/forgot_password_page.dart';
import 'bottom_sheet_pages/signin_page.dart';
import 'bottom_sheet_pages/signup_page.dart';
final authRoutes = [
TnRoute(
path: 'forgot-password',
builder: (context, email) => ForgotPasswordPage(email: email as String),
),
TnRoute(path: 'signin', builder: (_, __) => SignInPage()),
TnRoute(path: 'signup', builder: (_, __) => const SignUpPage()),
];
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'TnBottomSheetNavigator Sample',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
useMaterial3: true,
),
home: const AppContent(),
);
}
}
class AppContent extends StatelessWidget {
const AppContent({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('TnBottomSheetNavigator')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
child: const Text('Open Bottom Sheet Navigator'),
onPressed: () => showTnBottomSheet<void>(
context: context,
routes: authRoutes,
initialRoute: 'signin',
showDragHandle: true,
),
),
const SizedBox(height: 20),
const Text('Custom Implementations',
style: TextStyle(fontSize: 20)),
const SizedBox(height: 20),
ElevatedButton(
child: const Text('Cupertino Dialog'),
onPressed: () => showCupertinoDialog(
context: context,
builder: (context) => CupertinoAlertDialog(
content: Material(
// Avoids an odd background on the dialog
color: Colors.transparent,
child: TnNavigator(
routes: authRoutes,
initialRoute: 'signin',
),
),
),
),
),
const SizedBox(height: 20),
ElevatedButton(
child: const Text('Dialog'),
onPressed: () => showDialog(
context: context,
builder: (context) => AlertDialog(
content: Material(
color: Colors.transparent,
child: TnNavigator(
routes: authRoutes,
initialRoute: 'signin',
),
),
),
),
),
],
),
),
);
}
}