Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor state.dart (part 2) #596

Closed
wants to merge 50 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ada5786
move main_screen.dart into a separate folder
d-uzlov Oct 26, 2022
2cf0706
extract downloading screen into a separate class
d-uzlov Oct 26, 2022
7a30db9
extract ready screen into a separate class
d-uzlov Oct 26, 2022
6161510
extract aborting screen into a separate class
d-uzlov Oct 26, 2022
1711d08
move firebaseManager out of state
d-uzlov Oct 27, 2022
56db9a2
move boardDecoder out of state
d-uzlov Oct 27, 2022
26e4e9d
refactor state.dart
d-uzlov Oct 27, 2022
2e5255d
try to isolate state usage in ui
d-uzlov Oct 27, 2022
61c0649
refactor result screen
d-uzlov Oct 27, 2022
a0f92c0
refactor result screen
d-uzlov Oct 27, 2022
2b47f60
refactor config manager
d-uzlov Oct 27, 2022
683a9fa
refactor config manager
d-uzlov Oct 27, 2022
3d49ad6
refactor config manager
d-uzlov Oct 27, 2022
46f344e
refactor config manager
d-uzlov Oct 28, 2022
26dfc4c
refactor benchmarkstate
d-uzlov Oct 28, 2022
f2774be
refactor result manager
d-uzlov Oct 28, 2022
74c653e
refactor state.dart
d-uzlov Oct 28, 2022
288883f
refactor benchmarkstate, configmanager, taskrunner
d-uzlov Oct 28, 2022
1ec9391
refactor benchmarkstate
d-uzlov Oct 28, 2022
190682b
make resourcemanager private
d-uzlov Oct 28, 2022
69a962f
refactor benchmarkstate
d-uzlov Oct 28, 2022
4ea6914
extract lastresultmanager
d-uzlov Oct 28, 2022
454d781
refactor result restoration
d-uzlov Oct 28, 2022
6b520c2
refactor task selection saving
d-uzlov Oct 28, 2022
a96bcdc
add lastresultmanager provider
d-uzlov Oct 28, 2022
b2fa7c7
refactor benchmarkstate
d-uzlov Oct 28, 2022
5657c2f
move benchmarklist into tasklistmanager
d-uzlov Oct 28, 2022
49e6dbd
remove benchmarks getter from benchmarkstate
d-uzlov Oct 28, 2022
840af29
refactor benchmarkstate
d-uzlov Oct 28, 2022
4a1b9a4
use explicit state in benchmarkstate
d-uzlov Oct 29, 2022
8cbb57a
fix result restoration
d-uzlov Oct 29, 2022
7b681e9
fix aborting
d-uzlov Oct 29, 2022
55cee40
fix task selection saving
d-uzlov Oct 29, 2022
5e83d49
fix result history saving
d-uzlov Oct 29, 2022
41abe22
refactor starting benchmark
d-uzlov Oct 29, 2022
be3a49f
refactor benchmarkstate
d-uzlov Oct 29, 2022
8136d0b
fix result restoration on startup
d-uzlov Oct 29, 2022
f904b7e
refactor benchmarkstate
d-uzlov Oct 29, 2022
40e45c6
rename benchmarkstate to appstate
d-uzlov Oct 29, 2022
57659b7
move appstate to state folder
d-uzlov Oct 29, 2022
ae85106
extract appstatehelper
d-uzlov Oct 29, 2022
425dd12
refactor appstate
d-uzlov Oct 29, 2022
637a279
add documentation for appstate
d-uzlov Oct 29, 2022
9f1948c
add documentation to some classes
d-uzlov Oct 29, 2022
4b80e71
rename runMode readable field
d-uzlov Oct 29, 2022
6727432
move loadgenlogfilename to class level
d-uzlov Oct 29, 2022
ceb9837
fix fast mode cooldown duration
d-uzlov Oct 29, 2022
97e013b
fix config reading on first launch
d-uzlov Oct 30, 2022
b7207cb
adjust documentation in appstate
d-uzlov Oct 30, 2022
c551df3
Merge commit '38327317a45fd0593fb92240b14c4c0e99a46292' into 556/refa…
d-uzlov Oct 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor config manager
d-uzlov committed Oct 28, 2022
commit 46f344efea0f09427db146a8c785db199433ff91
1 change: 1 addition & 0 deletions flutter/lib/main.dart
Original file line number Diff line number Diff line change
@@ -66,6 +66,7 @@ Future<void> launchUi() async {
ChangeNotifierProvider.value(value: store),
Provider.value(value: FirebaseManager.instance),
Provider.value(value: boardDecoder),
Provider.value(value: benchmarkState.configManager),
],
child: const MyApp(home: MyHomePage()),
),
16 changes: 9 additions & 7 deletions flutter/lib/ui/root/resource_error_screen.dart
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import 'package:provider/provider.dart';
import 'package:mlperfbench/app_constants.dart';
import 'package:mlperfbench/benchmark/state.dart';
import 'package:mlperfbench/localizations/app_localizations.dart';
import 'package:mlperfbench/store.dart';
import 'package:mlperfbench/resources/config_manager.dart';
import 'package:mlperfbench/ui/error_dialog.dart';
import 'package:mlperfbench/ui/icons.dart' show AppIcons;
import 'package:mlperfbench/ui/page_constraints.dart';
@@ -18,7 +18,10 @@ class ResourceErrorScreen extends StatelessWidget {
Widget build(BuildContext context) {
final stringResources = AppLocalizations.of(context);
final state = context.watch<BenchmarkState>();
final store = context.watch<Store>();
final configManager = context.watch<ConfigManager>();

final error =
context.select<BenchmarkState, Object?>((value) => value.error);

final iconEdgeSize = MediaQuery.of(context).size.width * 0.66;

@@ -46,7 +49,7 @@ class ResourceErrorScreen extends StatelessWidget {
child: Column(
children: [
Text(
'Error: ${state.error}\n',
'Error: $error\n',
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 15,
@@ -62,7 +65,7 @@ class ResourceErrorScreen extends StatelessWidget {
),
),
Text(
'${stringResources.resourceErrorCurrentConfig} ${state.configManager.currentConfigFilePath}',
'${stringResources.resourceErrorCurrentConfig} ${configManager.currentConfigFilePath}',
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 15,
@@ -90,9 +93,8 @@ class ResourceErrorScreen extends StatelessWidget {
TextButton(
onPressed: () async {
try {
await state.configManager
.setConfig(name: store.chosenConfigurationName);
state.deferredLoadResources();
await configManager.setConfig(
name: configManager.currentConfigName);
} catch (e, trace) {
print("can't change task config: $e");
print(trace);
10 changes: 6 additions & 4 deletions flutter/lib/ui/run/result_screen.dart
Original file line number Diff line number Diff line change
@@ -309,7 +309,9 @@ class _ResultScreenState extends State<ResultScreen>
@override
Widget build(BuildContext context) {
final state = context.watch<BenchmarkState>();
final store = context.watch<Store>();
final shareEnabled = context.select<Store, bool>((value) => value.share);
final offlineMode =
context.select<Store, bool>((value) => value.offlineMode);
final stringResources = AppLocalizations.of(context);
final scrollController = ScrollController();

@@ -401,7 +403,7 @@ class _ResultScreenState extends State<ResultScreen>
await showErrorDialog(context, [wrongPathError]);
return;
}
if (store.offlineMode) {
if (offlineMode) {
final offlineError = await state.validator.validateOfflineMode(
stringResources.dialogContentOfflineWarning);
if (offlineError.isNotEmpty) {
@@ -438,7 +440,7 @@ class _ResultScreenState extends State<ResultScreen>
),
),
)),
store.share
shareEnabled
? Padding(
padding: const EdgeInsets.fromLTRB(10, 10, 10, 10),
child: TextButton(
@@ -460,7 +462,7 @@ class _ResultScreenState extends State<ResultScreen>
),
)
: Container(),
store.share && fm != null
shareEnabled && fm != null
? Padding(
padding: const EdgeInsets.fromLTRB(10, 10, 10, 10),
child: TextButton(
12 changes: 5 additions & 7 deletions flutter/lib/ui/settings/task_config_screen.dart
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ import 'package:file_picker/file_picker.dart';
import 'package:provider/provider.dart';

import 'package:mlperfbench/app_constants.dart';
import 'package:mlperfbench/benchmark/state.dart';
import 'package:mlperfbench/localizations/app_localizations.dart';
import 'package:mlperfbench/resources/config_manager.dart';
import 'package:mlperfbench/store.dart';
@@ -166,7 +165,7 @@ class TaskConfigScreen extends StatelessWidget {
String chosenConfigName,
) {
final stringResources = AppLocalizations.of(context);
final state = context.watch<BenchmarkState>();
final configManager = context.watch<ConfigManager>();
final wasChosen = chosenConfigName == configuration.name;

return Card(
@@ -180,7 +179,7 @@ class TaskConfigScreen extends StatelessWidget {
trailing: Text(configuration.getType(stringResources)),
onTap: () async {
try {
await state.configManager.setConfig(name: configuration.name);
await configManager.setConfig(name: configuration.name);
// TODO (anhappdev): Uncomment the if line and remove the ignore line, when updated to Flutter v3.4.
// See https://github.com/flutter/flutter/issues/111488
// if (!context.mounted) return;
@@ -229,10 +228,9 @@ class TaskConfigScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context);
final store = context.watch<Store>();
final state = context.watch<BenchmarkState>();
final configManager = context.watch<ConfigManager>();

final configs = state.configManager.configList.values;
final configs = configManager.configList.values;

return Scaffold(
appBar: AppBar(
@@ -252,7 +250,7 @@ class TaskConfigScreen extends StatelessWidget {
...configs.map((c) => _makeConfigListItem(
context,
c,
store.chosenConfigurationName,
configManager.currentConfigName,
)),
],
),