Skip to content

Commit

Permalink
Use page_transition to replace navigators/*
Browse files Browse the repository at this point in the history
  • Loading branch information
lijy91 committed Jan 16, 2022
1 parent 67c2943 commit 0953576
Show file tree
Hide file tree
Showing 30 changed files with 374 additions and 400 deletions.
16 changes: 5 additions & 11 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ PODS:
- device_info_plus (0.0.1):
- Flutter
- Flutter (1.0.0)
- network_info_plus (0.0.1):
- Flutter
- package_info_plus (0.4.5):
- Flutter
- path_provider_ios (0.0.1):
Expand All @@ -14,19 +12,18 @@ PODS:
- Flutter
- uni_links (0.0.1):
- Flutter
- url_launcher (0.0.1):
- url_launcher_ios (0.0.1):
- Flutter

DEPENDENCIES:
- audioplayers (from `.symlinks/plugins/audioplayers/ios`)
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- Flutter (from `Flutter`)
- network_info_plus (from `.symlinks/plugins/network_info_plus/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`)
- shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`)
- uni_links (from `.symlinks/plugins/uni_links/ios`)
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)

EXTERNAL SOURCES:
audioplayers:
Expand All @@ -35,8 +32,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/device_info_plus/ios"
Flutter:
:path: Flutter
network_info_plus:
:path: ".symlinks/plugins/network_info_plus/ios"
package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios"
path_provider_ios:
Expand All @@ -45,19 +40,18 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/shared_preferences_ios/ios"
uni_links:
:path: ".symlinks/plugins/uni_links/ios"
url_launcher:
:path: ".symlinks/plugins/url_launcher/ios"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"

SPEC CHECKSUMS:
audioplayers: 455322b54050b30ea4b1af7cd9e9d105f74efa8c
device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
network_info_plus: b78876159360f5580608c2cea620d6ceffabd0ad
package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e
path_provider_ios: 7d7ce634493af4477d156294792024ec3485acd5
shared_preferences_ios: aef470a42dc4675a1cdd50e3158b42e3d1232b32
uni_links: d97da20c7701486ba192624d99bffaaffcfc298a
url_launcher: b6e016d912f04be9f5bf6e8e82dc599b7ba59649
url_launcher_ios: 02f1989d4e14e998335b02b67a7590fa34f971af

PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c

Expand Down
2 changes: 1 addition & 1 deletion ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
1 change: 0 additions & 1 deletion lib/includes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export 'package:easy_localization/easy_localization.dart';

// 请按文件名排序放置
export './models/models.dart';
export './navigators/navigators.dart';
export './networking/networking.dart';
export './pages/pages.dart';
export './services/services.dart';
Expand Down
92 changes: 77 additions & 15 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import 'dart:io';

import 'package:anyinspect/anyinspect.dart';
import 'package:anyinspect_plugin_network/anyinspect_plugin_network.dart';
import 'package:anyinspect_plugin_shared_preferences/anyinspect_plugin_shared_preferences.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:easy_localization_loader/easy_localization_loader.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:launch_at_startup/launch_at_startup.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:window_manager/window_manager.dart';

import './includes.dart';

void main() async {
Future<void> _ensureInitialized() async {
WidgetsFlutterBinding.ensureInitialized();

await EasyLocalization.ensureInitialized();

await AudioPlayer.ensureInitialized();
if (kIsLinux || kIsMacOS || kIsWindows) {
await WindowManager.instance.ensureInitialized();
Expand All @@ -36,13 +30,10 @@ void main() async {
await initEnv();
await initLocalDb();
await initConfig();
}

if (!kReleaseMode) {
AnyInspect anyInspect = AnyInspect.instance;
anyInspect.addPlugin(AnyInspectPluginNetwork());
anyInspect.addPlugin(AnyInspectPluginSharedPreferences());
anyInspect.start();
}
void main() async {
await _ensureInitialized();

runApp(
EasyLocalization(
Expand All @@ -56,7 +47,78 @@ void main() async {
path: 'assets/translations',
assetLoader: YamlAssetLoader(),
fallbackLocale: const Locale(kLanguageEN),
child: const AppNavigator(),
child: const MyApp(),
),
);
}

class MyApp extends StatefulWidget {
const MyApp({
Key key,
}) : super(key: key);

@override
_MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
final GlobalKey<NavigatorState> _navigatorKey = GlobalKey<NavigatorState>();

ThemeMode _themeMode = ThemeMode.system;

@override
void initState() {
super.initState();
sharedConfigManager.addListener(_configListen);
_init();
}

@override
void dispose() {
sharedConfigManager.removeListener(_configListen);
super.dispose();
}

void _configListen() {
_themeMode = sharedConfig.themeMode;
setState(() {});
}

void _init() async {
_themeMode = sharedConfig.themeMode;
setState(() {});
}

Widget _buildHome(BuildContext context) {
if (kIsAndroid || kIsIOS) {
return const HomePage();
}
return const DesktopPopupPage();
}

@override
Widget build(BuildContext context) {
final virtualWindowFrameBuilder = VirtualWindowFrameInit();
final botToastBuilder = BotToastInit();

return MaterialApp(
debugShowCheckedModeBanner: false,
navigatorKey: _navigatorKey,
theme: lightThemeData,
darkTheme: darkThemeData,
themeMode: _themeMode,
builder: (context, child) {
if (kIsLinux || kIsWindows) {
child = virtualWindowFrameBuilder(context, child);
}
child = botToastBuilder(context, child);
return child;
},
navigatorObservers: [BotToastNavigatorObserver()],
localizationsDelegates: context.localizationDelegates,
supportedLocales: context.supportedLocales,
locale: context.locale,
home: _buildHome(context),
);
}
}
77 changes: 0 additions & 77 deletions lib/navigators/app_navigator.dart

This file was deleted.

27 changes: 0 additions & 27 deletions lib/navigators/fadein_page_route.dart

This file was deleted.

3 changes: 0 additions & 3 deletions lib/navigators/navigators.dart

This file was deleted.

15 changes: 6 additions & 9 deletions lib/pages/desktop_popup/toolbar_item_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,12 @@ class _ToolbarItemSettingsState extends State<ToolbarItemSettings> {
),
clipBehavior: Clip.antiAliasWithSaveLayer,
builder: (ctx) {
return SizedBox(
height: 600,
child: AppNavigator(
home: SettingsPage(
onDismiss: () {
Navigator.of(ctx).pop();
_handleDismiss();
},
),
return ModalBottomSheetWrapped(
child: SettingsPage(
onDismiss: () {
Navigator.of(ctx).pop();
_handleDismiss();
},
),
);
},
Expand Down
Loading

0 comments on commit 0953576

Please sign in to comment.