diff --git a/lib/src/localization/app_localizations.dart b/lib/src/localization/app_localizations.dart index c3a351e..2112a3d 100644 --- a/lib/src/localization/app_localizations.dart +++ b/lib/src/localization/app_localizations.dart @@ -63,7 +63,7 @@ import 'app_localizations_ru.dart'; /// property. abstract class AppLocalizations { AppLocalizations(String locale) - : localeName = intl.Intl.canonicalizedLocale(locale.toString()); + : localeName = intl.Intl.canonicalizedLocale(locale.toString()); final String localeName; @@ -86,16 +86,16 @@ abstract class AppLocalizations { /// of delegates is preferred or required. static const List> localizationsDelegates = >[ - delegate, - GlobalMaterialLocalizations.delegate, - GlobalCupertinoLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - ]; + delegate, + GlobalMaterialLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ]; /// A list of this localizations delegate's supported locales. static const List supportedLocales = [ Locale('en'), - Locale('ru'), + Locale('ru') ]; /// The title of the application @@ -132,9 +132,8 @@ AppLocalizations lookupAppLocalizations(Locale locale) { } throw FlutterError( - 'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely ' - 'an issue with the localizations generation tool. Please file an issue ' - 'on GitHub with a reproducible sample app and the gen-l10n configuration ' - 'that was used.', - ); + 'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely ' + 'an issue with the localizations generation tool. Please file an issue ' + 'on GitHub with a reproducible sample app and the gen-l10n configuration ' + 'that was used.'); } diff --git a/lib/src/screens/foreground_switch_screen.dart b/lib/src/screens/foreground_switch_screen.dart index b359d16..8738201 100644 --- a/lib/src/screens/foreground_switch_screen.dart +++ b/lib/src/screens/foreground_switch_screen.dart @@ -1,4 +1,6 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:md_ui_kit/widgets/gradient_scaffold_wrapper.dart'; import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:wave_p2p/src/core/keys.dart'; @@ -90,101 +92,178 @@ class ForegroundSwitchScreenState extends State { switch (stepper) { // Экран с кнопкой "Start", скрывается если нажался хотя бы раз case VisibleScreenType.startButton: - return StartScreen( - key: ValueKey('startButton$postfix'), - onNext: _onStartButtonPressed, + return GradientScaffoldWrapper( + showLogo: true, + showArrow: false, + iosTopPadding: kIsWeb ? 28 : 90, + onTapBack: () { + setState(() { + _stepper = VisibleScreenType.selectAction; + }); + }, + child: StartScreen( + key: ValueKey('startButton$postfix'), + onNext: _onStartButtonPressed, + ), ); // Экран с кнопкой "Mic on", скрывается если нажался хотя бы раз // без анимации, если проигрывается после startButton case VisibleScreenType.micOn: - return AnimatedContainerWrapper( - purpleTitle: 'One more step', - isAnimated: false, - key: ValueKey('micOn$postfix'), - topPadding: topPadding, - child: EnableMicrophoneScreen( - onNext: _onEnableMicPressed, + return GradientScaffoldWrapper( + showLogo: true, + showArrow: false, + iosTopPadding: kIsWeb ? 28 : 90, + onTapBack: () { + setState(() { + _stepper = VisibleScreenType.selectAction; + }); + }, + child: AnimatedContainerWrapper( + purpleTitle: 'One more step', + isAnimated: false, + key: ValueKey('micOn$postfix'), + topPadding: topPadding, + child: EnableMicrophoneScreen( + onNext: _onEnableMicPressed, + ), ), ); // Экран с кнопкой "Mic on", скрывается если нажался хотя бы раз // с анимацией, если открывается сразу после заставки case VisibleScreenType.micOnAnimated: - return AnimatedContainerWrapper( - purpleTitle: 'One more step', - isAnimated: true, - key: ValueKey('minOnAnimated$postfix'), - topPadding: topPadding, - child: EnableMicrophoneScreen( - onNext: _onEnableMicPressed, + return GradientScaffoldWrapper( + showLogo: true, + showArrow: false, + iosTopPadding: kIsWeb ? 28 : 90, + onTapBack: () { + setState(() { + _stepper = VisibleScreenType.selectAction; + }); + }, + child: AnimatedContainerWrapper( + purpleTitle: 'One more step', + isAnimated: true, + key: ValueKey('minOnAnimated$postfix'), + topPadding: topPadding, + child: EnableMicrophoneScreen( + onNext: _onEnableMicPressed, + ), ), ); // Экран с выбором действия - создать/вставить код // без анимации, если проигрывается после micOn case VisibleScreenType.selectAction: - return AnimatedContainerWrapper( - isAnimated: false, - key: ValueKey('selectAction$postfix'), - topPadding: topPadding, - child: StartConnectionScreen( - onCreateCode: _onCreateCodePressed, - onPasteCode: _onPasteCodePressed, - // TODO: remove reconnect functionality - onOrPressed: _onOrPressed, + return GradientScaffoldWrapper( + showLogo: true, + showArrow: false, + iosTopPadding: kIsWeb ? 28 : 90, + onTapBack: () { + setState(() { + _stepper = VisibleScreenType.selectAction; + }); + }, + child: AnimatedContainerWrapper( + isAnimated: false, + key: ValueKey('selectAction$postfix'), + topPadding: topPadding, + child: StartConnectionScreen( + onCreateCode: _onCreateCodePressed, + onPasteCode: _onPasteCodePressed, + // TODO: remove reconnect functionality + onOrPressed: _onOrPressed, + ), ), ); // Экран с выбором действия - создать/вставить код // без анимации, если проигрывается после micOn case VisibleScreenType.selectActionAnimated: - return AnimatedContainerWrapper( - key: ValueKey('selectActionAnimated$postfix'), - topPadding: topPadding, - isAnimated: true, - child: StartConnectionScreen( - onCreateCode: _onCreateCodePressed, - onPasteCode: _onPasteCodePressed, - // TODO: remove reconnect functionality - onOrPressed: _onOrPressed, + return GradientScaffoldWrapper( + showLogo: true, + showArrow: false, + iosTopPadding: kIsWeb ? 28 : 90, + onTapBack: () { + setState(() { + _stepper = VisibleScreenType.selectAction; + }); + }, + child: AnimatedContainerWrapper( + key: ValueKey('selectActionAnimated$postfix'), + topPadding: topPadding, + isAnimated: true, + child: StartConnectionScreen( + onCreateCode: _onCreateCodePressed, + onPasteCode: _onPasteCodePressed, + // TODO: remove reconnect functionality + onOrPressed: _onOrPressed, + ), ), ); // Экран создания кода case VisibleScreenType.createCode: - return AnimatedContainerWrapper( - key: ValueKey('createCode$postfix'), - topPadding: topPadding, - isAnimated: false, - child: CopyCodeScreen( - onCheckPairPressed: _onCheckPairPressed, + return GradientScaffoldWrapper( + showLogo: true, + iosTopPadding: kIsWeb ? 28 : 90, + onTapBack: () { + setState(() { + _stepper = VisibleScreenType.selectAction; + }); + }, + child: AnimatedContainerWrapper( + key: ValueKey('createCode$postfix'), + topPadding: topPadding, + isAnimated: false, + child: CopyCodeScreen( + onCheckPairPressed: _onCheckPairPressed, + ), ), ); // Экран вставки кода case VisibleScreenType.pasteCode: - return AnimatedContainerWrapper( - key: ValueKey('pasteCode$postfix'), - topPadding: topPadding, - isAnimated: false, - child: PasteCodeScreen( - onConnectPressed: _onCheckAnswerPressed, + return GradientScaffoldWrapper( + showLogo: true, + iosTopPadding: kIsWeb ? 28 : 90, + onTapBack: () { + setState(() { + _stepper = VisibleScreenType.selectAction; + }); + }, + child: AnimatedContainerWrapper( + key: ValueKey('pasteCode$postfix'), + topPadding: topPadding, + isAnimated: false, + child: PasteCodeScreen( + onConnectPressed: _onCheckAnswerPressed, + ), ), ); // Основной экран с динамичным навбаром, скаффолдом с адаптивной высотой и волной case VisibleScreenType.main: - return MainScreen( - key: ValueKey('main$postfix'), - topPadding: topPadding, - isPeerInitiator: _isPeerInitiator, - onReturnPressed: () { + return GradientScaffoldWrapper( + showLogo: true, + iosTopPadding: kIsWeb ? 28 : 90, + onTapBack: () { setState(() { _stepper = VisibleScreenType.selectAction; }); }, - onClosePeerPressed: _onClosePeerPressed, + child: MainScreen( + key: ValueKey('main$postfix'), + topPadding: topPadding, + isPeerInitiator: _isPeerInitiator, + onReturnPressed: () { + setState(() { + _stepper = VisibleScreenType.selectAction; + }); + }, + onClosePeerPressed: _onClosePeerPressed, + ), ); // TODO: DO NOT REMOVE TO PREFENT FAILURE ON PROD diff --git a/lib/src/screens/home_screen.dart b/lib/src/screens/home_screen.dart deleted file mode 100644 index d10f8bd..0000000 --- a/lib/src/screens/home_screen.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:md_ui_kit/md_ui_kit.dart'; - -import 'package:wave_p2p/src/screens/foreground_switch_screen.dart'; - -class HomeScreen extends StatelessWidget { - const HomeScreen({super.key}); - - @override - Widget build(BuildContext context) { - return GradientScaffoldWrapper( - showLogo: true, - iosTopPadding: kIsWeb ? 28 : 90, - child: ForegroundSwitchScreen(), - ); - } -} diff --git a/lib/src/screens/initial_screen_impl.dart b/lib/src/screens/initial_screen_impl.dart index 75cf36c..3b0e0b8 100644 --- a/lib/src/screens/initial_screen_impl.dart +++ b/lib/src/screens/initial_screen_impl.dart @@ -3,7 +3,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:md_ui_kit/_core/colors.dart'; import 'package:md_ui_kit/screens/initial_screen.dart'; -import 'package:wave_p2p/src/screens/home_screen.dart'; +import 'package:wave_p2p/src/screens/foreground_switch_screen.dart'; class InitialScreenImpl extends StatefulWidget { const InitialScreenImpl({super.key}); @@ -37,13 +37,11 @@ class _InitialScreenImplState extends State { @override Widget build(BuildContext context) { - return - kDebugMode - ? HomeScreen( + return kDebugMode + ? ForegroundSwitchScreen( key: ValueKey("home"), ) - : - AnimatedSwitcher( + : AnimatedSwitcher( duration: const Duration(milliseconds: 400), layoutBuilder: (currentChild, previousChildren) { return DecoratedBox( @@ -75,7 +73,7 @@ class _InitialScreenImplState extends State { wavePositionedBottom: kIsWeb ? 120 : 100, ); case false: - return const HomeScreen( + return const ForegroundSwitchScreen( key: ValueKey("home"), ); } diff --git a/lib/src/wave_app.dart b/lib/src/wave_app.dart index 9343ba8..b89d7ea 100644 --- a/lib/src/wave_app.dart +++ b/lib/src/wave_app.dart @@ -11,7 +11,6 @@ import 'package:wave_p2p/src/screens/initial_screen_impl.dart'; import 'settings/settings_controller.dart'; import 'settings/settings_view.dart'; - /// The Widget that configures your application. class WaveApp extends StatelessWidget { const WaveApp({ @@ -38,59 +37,59 @@ class WaveApp extends StatelessWidget { listenable: settingsController, builder: (BuildContext context, Widget? child) { return MaterialApp( - debugShowCheckedModeBanner: false, - // Providing a restorationScopeId allows the Navigator built by the - // MaterialApp to restore the navigation stack when a user leaves and - // returns to the app after it has been killed while running in the - // background. - restorationScopeId: 'app', + debugShowCheckedModeBanner: false, + // Providing a restorationScopeId allows the Navigator built by the + // MaterialApp to restore the navigation stack when a user leaves and + // returns to the app after it has been killed while running in the + // background. + restorationScopeId: 'app', - // Provide the generated AppLocalizations to the MaterialApp. This - // allows descendant Widgets to display the correct translations - // depending on the user's locale. - localizationsDelegates: const [ - AppLocalizations.delegate, - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - GlobalCupertinoLocalizations.delegate, - ], - supportedLocales: const [ - Locale('ru', ''), // English, no country code - ], + // Provide the generated AppLocalizations to the MaterialApp. This + // allows descendant Widgets to display the correct translations + // depending on the user's locale. + localizationsDelegates: const [ + AppLocalizations.delegate, + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], + supportedLocales: const [ + Locale('ru', ''), // English, no country code + ], - // Use AppLocalizations to configure the correct application title - // depending on the user's locale. - // - // The appTitle is defined in .arb files found in the localization - // directory. - onGenerateTitle: (BuildContext context) => - AppLocalizations.of(context)!.appTitle, + // Use AppLocalizations to configure the correct application title + // depending on the user's locale. + // + // The appTitle is defined in .arb files found in the localization + // directory. + onGenerateTitle: (BuildContext context) => + AppLocalizations.of(context)!.appTitle, - // Define a light and dark color theme. Then, read the user's - // preferred ThemeMode (light, dark, or system default) from the - // SettingsController to display the correct theme. - theme: ThemeData(), - darkTheme: ThemeData.dark(), - themeMode: settingsController.themeMode, + // Define a light and dark color theme. Then, read the user's + // preferred ThemeMode (light, dark, or system default) from the + // SettingsController to display the correct theme. + theme: ThemeData(), + darkTheme: ThemeData.dark(), + themeMode: settingsController.themeMode, - // Define a function to handle named routes in order to support - // Flutter web url navigation and deep linking. - onGenerateRoute: (RouteSettings routeSettings) { - return MaterialPageRoute( - settings: routeSettings, - builder: (BuildContext context) { - switch (routeSettings.name) { - case SettingsView.routeName: - return SettingsView(controller: settingsController); - // case SampleItemDetailsView.routeName: - // return const SampleItemDetailsView(); - // case SampleItemListView.routeName: - default: - return const InitialScreenImpl(); - } - }, - ); - }, + // Define a function to handle named routes in order to support + // Flutter web url navigation and deep linking. + onGenerateRoute: (RouteSettings routeSettings) { + return MaterialPageRoute( + settings: routeSettings, + builder: (BuildContext context) { + switch (routeSettings.name) { + case SettingsView.routeName: + return SettingsView(controller: settingsController); + // case SampleItemDetailsView.routeName: + // return const SampleItemDetailsView(); + // case SampleItemListView.routeName: + default: + return const InitialScreenImpl(); + } + }, + ); + }, ); }, ), diff --git a/pubspec.lock b/pubspec.lock index faa64c9..dffa822 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -329,22 +329,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.1" - flex_color_scheme: - dependency: transitive - description: - name: flex_color_scheme - sha256: "3344f8f6536c6ce0473b98e9f084ef80ca89024ad3b454f9c32cf840206f4387" - url: "https://pub.dev" - source: hosted - version: "8.2.0" - flex_seed_scheme: - dependency: transitive - description: - name: flex_seed_scheme - sha256: b06d8b367b84cbf7ca5c5603c858fa5edae88486c4e4da79ac1044d73b6c62ec - url: "https://pub.dev" - source: hosted - version: "3.5.1" flutter: dependency: "direct main" description: flutter @@ -554,10 +538,10 @@ packages: description: path: "." ref: master - resolved-ref: "64b3089e8732498e3417bfc201463395119b7e3f" + resolved-ref: e9fb4e48d48135f80a74c8ec50de8ac056a0effb url: "https://github.com/Miracle-Development/md_ui_kit.git" source: git - version: "2.15.3" + version: "3.0.1" meta: dependency: transitive description: