From 2c2221f7f1c190ef53048ac86169e069f9b56b17 Mon Sep 17 00:00:00 2001 From: Sergey Elpashev Date: Sun, 12 May 2024 13:53:29 +0300 Subject: [PATCH] "Steal" theme from example app --- lib/mobile_example.dart | 61 +++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/lib/mobile_example.dart b/lib/mobile_example.dart index 8aea581..a74fee9 100644 --- a/lib/mobile_example.dart +++ b/lib/mobile_example.dart @@ -1,7 +1,7 @@ import 'dart:math'; import 'package:flutter/material.dart'; -import 'package:gymlink_module_web/main_mobile.dart'; +import 'package:gymlink_module_web/pages/main.dart'; import 'package:gymlink_module_web/providers/main.dart'; import 'package:provider/provider.dart'; @@ -23,6 +23,7 @@ class MyExampleApp extends StatelessWidget { builder: (context, provider, __) => const ExamplePage(), ), ), + theme: ThemeData.dark(), ); } } @@ -38,38 +39,40 @@ class _ExamplePageState extends State { @override void initState() { super.initState(); - context.read().onTokenReceived('token123'); + Future.microtask( + () => context.read().onTokenReceived('token123')); } @override Widget build(BuildContext context) { - return Consumer( - builder: (context, provider, __) => Scaffold( - appBar: AppBar(title: const Text('GymLink Example App')), - body: Column( - children: [ - const Text('test'), - IconButton( - icon: const Icon(Icons.abc), - onPressed: () { - provider.onTokenReceived('token123'); - }, - ), - const Expanded( - child: MyApp(), - ), - const SizedBox( - height: 20, - ), - const Text('Bottom text') - ], - ), - floatingActionButton: IconButton( - icon: const Icon(Icons.search), - onPressed: () { - provider.changeTheme(Random().nextInt(0xffffff + 1)); - }, - ), + return Scaffold( + appBar: AppBar(title: const Text('GymLink Example App')), + body: Column( + children: [ + const Text('test'), + IconButton( + icon: const Icon(Icons.abc), + onPressed: () { + context.read().onTokenReceived('token123'); + }, + ), + Expanded( + child: + MainPage(isLoading: context.watch().isLoading), + ), + const SizedBox( + height: 20, + ), + const Text('Bottom text') + ], + ), + floatingActionButton: IconButton( + icon: const Icon(Icons.search), + onPressed: () { + context + .read() + .changeTheme(Random().nextInt(0xffffff + 1)); + }, ), ); }