Error provider
This commit is contained in:
@@ -6,13 +6,13 @@ import 'package:flutter/material.dart';
|
||||
import 'package:gymlink_module_web/main.dart';
|
||||
import 'package:gymlink_module_web/pages/main.dart';
|
||||
import 'package:gymlink_module_web/providers/cart.dart';
|
||||
import 'package:gymlink_module_web/providers/main.dart';
|
||||
import 'package:gymlink_module_web/theme.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@js.JSExport()
|
||||
class MyAppStateWeb extends State<MyApp> {
|
||||
final _streamController = StreamController<void>.broadcast();
|
||||
bool _isLoading = true;
|
||||
ThemeData theme = myTheme;
|
||||
bool black_theme = false;
|
||||
|
||||
@@ -32,31 +32,33 @@ class MyAppStateWeb extends State<MyApp> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = context.watch<GymLinkProvider>().theme;
|
||||
final isLoading = context.watch<GymLinkProvider>().isLoading;
|
||||
return ChangeNotifierProvider(
|
||||
create: (_) => CartProvider(),
|
||||
child: MaterialApp(
|
||||
title: 'GymLink Module',
|
||||
theme: theme,
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: MainPage(isLoading: _isLoading),
|
||||
),
|
||||
child: isLoading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: MaterialApp(
|
||||
title: 'GymLink Module',
|
||||
theme: theme,
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: const MainPage(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@js.JSExport()
|
||||
void onTokenReceived(String token) {
|
||||
if (token == 'token123') {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
context.read<GymLinkProvider>().onTokenReceived(token);
|
||||
}
|
||||
|
||||
@js.JSExport()
|
||||
void changeColor(int color) {
|
||||
setState(() {
|
||||
black_theme = !black_theme; //FIXME: TEMPORARY
|
||||
theme = getThemeData(Color(color), black_theme);
|
||||
});
|
||||
context.read<GymLinkProvider>().changeTheme(color);
|
||||
}
|
||||
|
||||
@js.JSExport()
|
||||
void setOnError(void Function() onError) {
|
||||
context.read<GymLinkProvider>().setOnError(onError);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user