mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-17 22:03:41 +00:00
fix: foreground task scope (#314)
This commit is contained in:
2 files changed
+153
-153
No files matched your search
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_foreground_task/flutter_foreground_task.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
@@ -14,22 +15,24 @@ class AppView extends GetView<AppController> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final config = controller.downloaderConfig.value;
|
final config = controller.downloaderConfig.value;
|
||||||
return GetMaterialApp.router(
|
return WithForegroundTask(
|
||||||
useInheritedMediaQuery: true,
|
child: GetMaterialApp.router(
|
||||||
debugShowCheckedModeBanner: false,
|
useInheritedMediaQuery: true,
|
||||||
theme: GopeedTheme.light,
|
debugShowCheckedModeBanner: false,
|
||||||
darkTheme: GopeedTheme.dark,
|
theme: GopeedTheme.light,
|
||||||
themeMode: ThemeMode.values.byName(config.extra.themeMode),
|
darkTheme: GopeedTheme.dark,
|
||||||
translations: messages,
|
themeMode: ThemeMode.values.byName(config.extra.themeMode),
|
||||||
locale: toLocale(config.extra.locale),
|
translations: messages,
|
||||||
fallbackLocale: fallbackLocale,
|
locale: toLocale(config.extra.locale),
|
||||||
localizationsDelegates: const [
|
fallbackLocale: fallbackLocale,
|
||||||
GlobalMaterialLocalizations.delegate,
|
localizationsDelegates: const [
|
||||||
GlobalWidgetsLocalizations.delegate,
|
GlobalMaterialLocalizations.delegate,
|
||||||
GlobalCupertinoLocalizations.delegate,
|
GlobalWidgetsLocalizations.delegate,
|
||||||
],
|
GlobalCupertinoLocalizations.delegate,
|
||||||
supportedLocales: messages.keys.keys.map((e) => toLocale(e)).toList(),
|
],
|
||||||
getPages: AppPages.routes,
|
supportedLocales: messages.keys.keys.map((e) => toLocale(e)).toList(),
|
||||||
|
getPages: AppPages.routes,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_foreground_task/flutter_foreground_task.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
import '../../../routes/app_pages.dart';
|
import '../../../routes/app_pages.dart';
|
||||||
@@ -12,7 +11,7 @@ class HomeView extends GetView<HomeController> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GetRouterOutlet.builder(builder: (context, delegate, currentRoute) {
|
return GetRouterOutlet.builder(builder: (context, delegate, currentRoute) {
|
||||||
switch (currentRoute?.location) {
|
switch (currentRoute?.uri.path) {
|
||||||
case Routes.EXTENSION:
|
case Routes.EXTENSION:
|
||||||
controller.currentIndex.value = 1;
|
controller.currentIndex.value = 1;
|
||||||
break;
|
break;
|
||||||
@@ -24,141 +23,139 @@ class HomeView extends GetView<HomeController> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return WithForegroundTask(
|
return Scaffold(
|
||||||
child: Scaffold(
|
// extendBody: true,
|
||||||
// extendBody: true,
|
body: Row(
|
||||||
body: Row(
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
children: [
|
||||||
children: [
|
!ResponsiveBuilder.isNarrow(context)
|
||||||
!ResponsiveBuilder.isNarrow(context)
|
? NavigationRail(
|
||||||
? NavigationRail(
|
extended: true,
|
||||||
extended: true,
|
labelType: NavigationRailLabelType.none,
|
||||||
labelType: NavigationRailLabelType.none,
|
minExtendedWidth: 170,
|
||||||
minExtendedWidth: 170,
|
groupAlignment: 0,
|
||||||
groupAlignment: 0,
|
// useIndicator: false,
|
||||||
// useIndicator: false,
|
onDestinationSelected: (int index) {
|
||||||
onDestinationSelected: (int index) {
|
controller.currentIndex.value = index;
|
||||||
controller.currentIndex.value = index;
|
switch (index) {
|
||||||
switch (index) {
|
case 0:
|
||||||
case 0:
|
delegate.offAndToNamed(Routes.TASK);
|
||||||
delegate.offAndToNamed(Routes.TASK);
|
break;
|
||||||
break;
|
case 1:
|
||||||
case 1:
|
delegate.offAndToNamed(Routes.EXTENSION);
|
||||||
delegate.offAndToNamed(Routes.EXTENSION);
|
break;
|
||||||
break;
|
case 2:
|
||||||
case 2:
|
delegate.offAndToNamed(Routes.SETTING);
|
||||||
delegate.offAndToNamed(Routes.SETTING);
|
break;
|
||||||
break;
|
}
|
||||||
}
|
},
|
||||||
},
|
destinations: [
|
||||||
destinations: [
|
NavigationRailDestination(
|
||||||
NavigationRailDestination(
|
icon: const Icon(Icons.task),
|
||||||
icon: const Icon(Icons.task),
|
selectedIcon: const Icon(Icons.task),
|
||||||
selectedIcon: const Icon(Icons.task),
|
label: Text('task'.tr),
|
||||||
label: Text('task'.tr),
|
),
|
||||||
),
|
NavigationRailDestination(
|
||||||
NavigationRailDestination(
|
icon: const Icon(Icons.extension),
|
||||||
icon: const Icon(Icons.extension),
|
selectedIcon: const Icon(Icons.extension),
|
||||||
selectedIcon: const Icon(Icons.extension),
|
label: Text('extensions'.tr),
|
||||||
label: Text('extensions'.tr),
|
),
|
||||||
),
|
NavigationRailDestination(
|
||||||
NavigationRailDestination(
|
icon: const Icon(Icons.settings),
|
||||||
icon: const Icon(Icons.settings),
|
selectedIcon: const Icon(Icons.settings),
|
||||||
selectedIcon: const Icon(Icons.settings),
|
label: Text('setting'.tr),
|
||||||
label: Text('setting'.tr),
|
),
|
||||||
),
|
],
|
||||||
],
|
selectedIndex: controller.currentIndex.value,
|
||||||
selectedIndex: controller.currentIndex.value,
|
leading: const Icon(Icons.menu),
|
||||||
leading: const Icon(Icons.menu),
|
// trailing: const Icon(Icons.info_outline),
|
||||||
// trailing: const Icon(Icons.info_outline),
|
)
|
||||||
)
|
: const SizedBox.shrink(),
|
||||||
: const SizedBox.shrink(),
|
Expanded(
|
||||||
Expanded(
|
child: GetRouterOutlet(
|
||||||
child: GetRouterOutlet(
|
initialRoute: Routes.TASK,
|
||||||
initialRoute: Routes.TASK,
|
// anchorRoute: '/',
|
||||||
// anchorRoute: '/',
|
// filterPages: (afterAnchor) {
|
||||||
// filterPages: (afterAnchor) {
|
// logger.w(afterAnchor);
|
||||||
// logger.w(afterAnchor);
|
// logger.w(afterAnchor.take(1));
|
||||||
// logger.w(afterAnchor.take(1));
|
// return afterAnchor.take(1);
|
||||||
// return afterAnchor.take(1);
|
// },
|
||||||
// },
|
))
|
||||||
))
|
]),
|
||||||
]),
|
bottomNavigationBar: ResponsiveBuilder.isNarrow(context)
|
||||||
bottomNavigationBar: ResponsiveBuilder.isNarrow(context)
|
? BottomNavigationBar(
|
||||||
? BottomNavigationBar(
|
items: <BottomNavigationBarItem>[
|
||||||
items: <BottomNavigationBarItem>[
|
BottomNavigationBarItem(
|
||||||
BottomNavigationBarItem(
|
icon: const Icon(Icons.task),
|
||||||
icon: const Icon(Icons.task),
|
label: 'task'.tr,
|
||||||
label: 'task'.tr,
|
),
|
||||||
),
|
BottomNavigationBarItem(
|
||||||
BottomNavigationBarItem(
|
icon: const Icon(Icons.extension),
|
||||||
icon: const Icon(Icons.extension),
|
label: 'extensions'.tr,
|
||||||
label: 'extensions'.tr,
|
),
|
||||||
),
|
BottomNavigationBarItem(
|
||||||
BottomNavigationBarItem(
|
icon: const Icon(Icons.settings),
|
||||||
icon: const Icon(Icons.settings),
|
label: 'setting'.tr,
|
||||||
label: 'setting'.tr,
|
),
|
||||||
),
|
],
|
||||||
],
|
currentIndex: controller.currentIndex.value,
|
||||||
currentIndex: controller.currentIndex.value,
|
// selectedItemColor: Get.theme.highlightColor,
|
||||||
// selectedItemColor: Get.theme.highlightColor,
|
onTap: (index) {
|
||||||
onTap: (index) {
|
controller.currentIndex.value = index;
|
||||||
controller.currentIndex.value = index;
|
switch (index) {
|
||||||
switch (index) {
|
case 0:
|
||||||
case 0:
|
delegate.offAndToNamed(Routes.TASK);
|
||||||
delegate.offAndToNamed(Routes.TASK);
|
break;
|
||||||
break;
|
case 1:
|
||||||
case 1:
|
delegate.offAndToNamed(Routes.EXTENSION);
|
||||||
delegate.offAndToNamed(Routes.EXTENSION);
|
break;
|
||||||
break;
|
case 2:
|
||||||
case 2:
|
delegate.offAndToNamed(Routes.SETTING);
|
||||||
delegate.offAndToNamed(Routes.SETTING);
|
break;
|
||||||
break;
|
}
|
||||||
}
|
},
|
||||||
},
|
)
|
||||||
)
|
// StylishBottomBar(
|
||||||
// StylishBottomBar(
|
// option: AnimatedBarOptions(
|
||||||
// option: AnimatedBarOptions(
|
// iconSize: 32,
|
||||||
// iconSize: 32,
|
// barAnimation: BarAnimation.blink,
|
||||||
// barAnimation: BarAnimation.blink,
|
// iconStyle: IconStyle.Default,
|
||||||
// iconStyle: IconStyle.Default,
|
// opacity: 0.3,
|
||||||
// opacity: 0.3,
|
// ),
|
||||||
// ),
|
// items: [
|
||||||
// items: [
|
// BottomBarItem(
|
||||||
// BottomBarItem(
|
// icon: const Icon(Icons.file_download),
|
||||||
// icon: const Icon(Icons.file_download),
|
// selectedColor: Get.theme.primaryColor,
|
||||||
// selectedColor: Get.theme.primaryColor,
|
// title: Text('downloading'.tr)),
|
||||||
// title: Text('downloading'.tr)),
|
// BottomBarItem(
|
||||||
// BottomBarItem(
|
// icon: const Icon(Icons.done),
|
||||||
// icon: const Icon(Icons.done),
|
// selectedColor: Get.theme.primaryColor,
|
||||||
// selectedColor: Get.theme.primaryColor,
|
// title: Text('downloaded'.tr)),
|
||||||
// title: Text('downloaded'.tr)),
|
// BottomBarItem(
|
||||||
// BottomBarItem(
|
// icon: const Icon(Icons.settings),
|
||||||
// icon: const Icon(Icons.settings),
|
// selectedColor: Get.theme.primaryColor,
|
||||||
// selectedColor: Get.theme.primaryColor,
|
// title: Text('setting'.tr)),
|
||||||
// title: Text('setting'.tr)),
|
// ],
|
||||||
// ],
|
// // hasNotch: true,
|
||||||
// // hasNotch: true,
|
// currentIndex: controller.currentIndex.value,
|
||||||
// currentIndex: controller.currentIndex.value,
|
// onTap: (index) {
|
||||||
// onTap: (index) {
|
// switch (index) {
|
||||||
// switch (index) {
|
// case 0:
|
||||||
// case 0:
|
// delegate.toNamed(Routes.DOWNLOADING);
|
||||||
// delegate.toNamed(Routes.DOWNLOADING);
|
// controller.currentIndex.value = 0;
|
||||||
// controller.currentIndex.value = 0;
|
// break;
|
||||||
// break;
|
// case 1:
|
||||||
// case 1:
|
// delegate.toNamed(Routes.DOWNLOADED);
|
||||||
// delegate.toNamed(Routes.DOWNLOADED);
|
// controller.currentIndex.value = 1;
|
||||||
// controller.currentIndex.value = 1;
|
// break;
|
||||||
// break;
|
// case 2:
|
||||||
// case 2:
|
// delegate.toNamed(Routes.SETTING);
|
||||||
// delegate.toNamed(Routes.SETTING);
|
// controller.currentIndex.value = 2;
|
||||||
// controller.currentIndex.value = 2;
|
// break;
|
||||||
// break;
|
// }
|
||||||
// }
|
// },
|
||||||
// },
|
// )
|
||||||
// )
|
: const SizedBox.shrink(),
|
||||||
: const SizedBox.shrink(),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user