fix: some fixes in example app

This commit is contained in:
2024-06-24 14:08:02 +03:00
parent 7cb92a7b83
commit 946d2ada41
6 changed files with 95 additions and 123 deletions

View File

@@ -53,32 +53,49 @@ Widget getDrawer(BuildContext context) => Drawer(
children: [
const DrawerHeader(child: Text('Drawer Header')),
ListTile(
leading: const Icon(Icons.home),
title: const Text('Home'),
onTap: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const ExampleMainPage(),
),
),
),
ListTile(
leading: const Icon(Icons.sell),
title: const Text('Club 2'),
onTap: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => ChangeNotifierProvider(
create: (_) => GymLinkProvider(),
child: Consumer<GymLinkProvider>(
builder: (_, value, __) => const ExampleClub2Page(),
leading: const Icon(Icons.home),
title: const Text('Home'),
onTap: () {
Future.microtask(() async {
final prefs = await SharedPreferences.getInstance();
prefs.remove('token');
prefs.remove('history');
prefs.remove('cart');
prefs.remove('detail_history');
});
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (context) => const ExampleMainPage(),
),
),
),
),
),
);
}),
ListTile(
leading: const Icon(Icons.sell),
title: const Text('Club 2'),
onTap: () {
Future.microtask(() async {
final prefs = await SharedPreferences.getInstance();
prefs.remove('token');
prefs.remove('history');
prefs.remove('cart');
prefs.remove('detail_history');
});
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (context) => ChangeNotifierProvider(
create: (_) => GymLinkProvider(),
child: Consumer<GymLinkProvider>(
builder: (_, value, __) => const ExampleClub2Page(),
),
),
),
);
}),
ListTile(
leading: const Icon(Icons.search),
title: const Text('Example page'),
onTap: () => Navigator.of(context).push(MaterialPageRoute(
onTap: () =>
Navigator.of(context).pushReplacement(MaterialPageRoute(
builder: (context) => const ExampleSecondPage(),
)),
),
@@ -143,26 +160,25 @@ class _ExamplePageState extends State<ExamplePage> {
),
resizeToAvoidBottomInset: false,
drawer: getDrawer(context),
body: const Column(
body: Column(
children: [
Text('test'),
Expanded(
IconButton(
icon: const Icon(Icons.colorize),
onPressed: () {
context.read<GymLinkProvider>().changeTheme(
Random().nextInt(0xffffff + 1),
blackTheme: Random().nextBool());
},
),
const Expanded(
child: MyApp(),
),
SizedBox(
const SizedBox(
height: 20,
),
Text('Bottom text')
const Text('Bottom text')
],
),
floatingActionButton: IconButton(
icon: const Icon(Icons.search),
onPressed: () {
context.read<GymLinkProvider>().changeTheme(
Random().nextInt(0xffffff + 1),
blackTheme: Random().nextBool());
},
),
);
}
}
@@ -231,12 +247,6 @@ class _ExampleClub2PageState extends State<ExampleClub2Page> {
Text('Bottom text')
],
),
floatingActionButton: IconButton(
icon: const Icon(Icons.search),
onPressed: () {
// context.read<GymLinkProvider>().changeTheme(0xFFAABCAB);
},
),
);
}
}