-
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.
Merge branch 'main' into feature/widgetbook-preview-to-gh-pages
- Loading branch information
Showing
33 changed files
with
939 additions
and
493 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,51 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
|
||
import 'app_navigator_observer.dart'; | ||
import 'app_service.dart'; | ||
import 'bloc/app_bloc.dart'; | ||
import 'di.dart'; | ||
import 'l10n/app_localizations.dart'; | ||
import 'strings_context.dart'; | ||
import 'ui/app_theme.dart'; | ||
import 'ui/screens/main_screen.dart'; | ||
|
||
/// Main Material app. | ||
/// | ||
/// Consumes [AppService] to read its [AppService.incomingUri]. | ||
/// Gets [AppService] to read its [AppService.incomingUri]. | ||
/// | ||
/// Home is [MainScreen]. | ||
class App extends StatelessWidget { | ||
const App({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
// TODO Move "Consumer<AppService>" and additional code into MainScreen | ||
final home = Consumer<AppService>( | ||
builder: (context, appService, _) { | ||
return ValueListenableBuilder( | ||
valueListenable: appService.incomingUri, | ||
builder: (context, incomingUri, _) { | ||
// TODO Convert to stateful and show modal dialog with question whether to start over with different input file | ||
final appService = getIt.get<AppService>(); | ||
|
||
return MainScreen( | ||
incomingUri: incomingUri, | ||
); | ||
}, | ||
final home = ValueListenableBuilder( | ||
valueListenable: appService.incomingUri, | ||
builder: (context, incomingUri, _) { | ||
// TODO Convert to stateful and show modal dialog with question whether to start over with different input file | ||
|
||
return MainScreen( | ||
incomingUri: incomingUri, | ||
); | ||
}, | ||
); | ||
|
||
return MaterialApp( | ||
final app = MaterialApp( | ||
title: context.strings.appTitle, | ||
localizationsDelegates: AppLocalizations.localizationsDelegates, | ||
supportedLocales: AppLocalizations.supportedLocales, | ||
debugShowCheckedModeBanner: false, | ||
navigatorObservers: [AppNavigatorObserver()], | ||
theme: appTheme(context, brightness: Brightness.light), | ||
home: home, | ||
); | ||
|
||
// Normally, setting home Widget would be sufficient | ||
// However need to assign arguments to RouteSettings so it can be read | ||
// back when navigated from OnboardingScreen | ||
onGenerateRoute: (RouteSettings settings) { | ||
if (settings.name == '/') { | ||
return MaterialPageRoute( | ||
// ignore: prefer_const_constructors, prefer_const_literals_to_create_immutables | ||
settings: RouteSettings(name: '/', arguments: {}), | ||
builder: (_) => home, | ||
); | ||
} | ||
|
||
return null; | ||
}, | ||
return BlocProvider<AppBloc>( | ||
create: (_) => AppBloc(), | ||
child: app, | ||
); | ||
} | ||
} |
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,16 @@ | ||
import 'package:flutter_bloc/flutter_bloc.dart' show Bloc; | ||
|
||
import '../app.dart'; | ||
import 'app_event.dart'; | ||
|
||
export 'app_event.dart'; | ||
|
||
/// Bloc for the [App], where event type is used also as state, so it is | ||
/// used as simple event bus. | ||
class AppBloc extends Bloc<AppEvent, AppEvent?> { | ||
AppBloc() : super(null) { | ||
on<AppEvent>((event, emit) { | ||
emit(event); | ||
}); | ||
} | ||
} |
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,19 @@ | ||
import 'package:flutter/foundation.dart'; | ||
|
||
import 'app_bloc.dart'; | ||
|
||
/// Event for the [AppBloc]. | ||
@immutable | ||
sealed class AppEvent { | ||
const AppEvent(); | ||
|
||
@override | ||
String toString() { | ||
return "$runtimeType()"; | ||
} | ||
} | ||
|
||
/// "Request open file" event. | ||
class RequestOpenFileEvent extends AppEvent { | ||
const RequestOpenFileEvent() : super(); | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.