-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
190 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import 'package:audioplayers/audioplayers.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
import 'package:flutter_localizations/flutter_localizations.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:google_fonts/google_fonts.dart'; | ||
import 'package:wrestling_scoreboard_client/provider/local_preferences.dart'; | ||
import 'package:wrestling_scoreboard_client/provider/local_preferences_provider.dart'; | ||
import 'package:wrestling_scoreboard_client/routes/router.dart'; | ||
import 'package:wrestling_scoreboard_client/services/audio/audio.dart'; | ||
import 'package:wrestling_scoreboard_client/view/shortcuts/app_shortcuts.dart'; | ||
import 'package:wrestling_scoreboard_client/view/widgets/loading_builder.dart'; | ||
|
||
class WrestlingScoreboardApp extends ConsumerStatefulWidget { | ||
const WrestlingScoreboardApp({super.key}); | ||
|
||
@override | ||
ConsumerState<ConsumerStatefulWidget> createState() => WrestlingScoreboardAppState(); | ||
} | ||
|
||
class WrestlingScoreboardAppState extends ConsumerState<WrestlingScoreboardApp> { | ||
@override | ||
void initState() { | ||
super.initState(); | ||
|
||
// Need to init to listen to changes of settings. | ||
AudioCache.instance = AudioCache(prefix: ''); | ||
HornSound.init(); | ||
} | ||
|
||
ThemeData _buildTheme(brightness) { | ||
var baseTheme = ThemeData(brightness: brightness); | ||
return baseTheme.copyWith( | ||
textTheme: GoogleFonts.robotoTextTheme(baseTheme.textTheme), | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return FutureBuilder<Locale?>( | ||
future: ref.watch(localeNotifierProvider), | ||
builder: (context, localeSnapshot) { | ||
return LoadingBuilder<ThemeMode>( | ||
future: ref.watch(themeModeNotifierProvider), | ||
builder: (context, themeMode) { | ||
final materialApp = MaterialApp.router( | ||
title: AppLocalizations.of(context)?.appName ?? 'Wrestling Scoreboard', | ||
theme: _buildTheme(Brightness.light), | ||
darkTheme: _buildTheme(Brightness.dark), | ||
themeMode: themeMode, | ||
localizationsDelegates: const [ | ||
AppLocalizations.delegate, | ||
GlobalMaterialLocalizations.delegate, | ||
GlobalWidgetsLocalizations.delegate, | ||
GlobalCupertinoLocalizations.delegate, | ||
], | ||
supportedLocales: Preferences.supportedLanguages.values, | ||
locale: localeSnapshot.data, | ||
routerConfig: router, | ||
); | ||
return Shortcuts( | ||
shortcuts: appShortcuts, | ||
child: Consumer( | ||
builder: (context, ref, child) { | ||
return Actions(actions: <Type, Action<Intent>>{ | ||
AppActionIntent: CallbackAction<AppActionIntent>( | ||
onInvoke: (AppActionIntent intent) => intent.handle(context, ref), | ||
) | ||
}, child: materialApp); | ||
}, | ||
), | ||
); | ||
}, | ||
); | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:wrestling_scoreboard_client/app.dart'; | ||
import 'package:wrestling_scoreboard_client/mocks/provider/network_provider.dart'; | ||
import 'package:wrestling_scoreboard_client/provider/network_provider.dart'; | ||
|
||
final mockProviderScope = ProviderScope( | ||
overrides: [ | ||
dataManagerNotifierProvider.overrideWith(() => MockDataManagerNotifier()), | ||
], | ||
child: const WrestlingScoreboardApp(), | ||
); |
14 changes: 14 additions & 0 deletions
14
wrestling_scoreboard_client/lib/mocks/provider/network_provider.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
import 'package:wrestling_scoreboard_client/mocks/services/network/data_manager.dart'; | ||
import 'package:wrestling_scoreboard_client/provider/network_provider.dart'; | ||
import 'package:wrestling_scoreboard_client/services/network/data_manager.dart'; | ||
|
||
part 'network_provider.g.dart'; | ||
|
||
@Riverpod(keepAlive: true) | ||
class MockDataManagerNotifier extends _$MockDataManagerNotifier implements DataManagerNotifier { | ||
@override | ||
Raw<Future<DataManager>> build() async { | ||
return MockDataManager(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
wrestling_scoreboard_client/lib/mocks/provider/network_provider.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
wrestling_scoreboard_client/lib/provider/data_provider.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
10 changes: 2 additions & 8 deletions
10
wrestling_scoreboard_client/lib/provider/network_provider.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
wrestling_scoreboard_client/lib/provider/network_provider.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
wrestling_scoreboard_client/lib/services/network/remote/rest.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.