mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-11 21:31:40 +08:00
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/view_safe_area.dart';
|
||||
import 'package:PiliPlus/grpc/dyn.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/msg.dart';
|
||||
@@ -9,12 +8,8 @@ import 'package:PiliPlus/models/common/msg/msg_unread_type.dart';
|
||||
import 'package:PiliPlus/models/common/nav_bar_config.dart';
|
||||
import 'package:PiliPlus/pages/dynamics/controller.dart';
|
||||
import 'package:PiliPlus/pages/home/controller.dart';
|
||||
import 'package:PiliPlus/pages/mine/view.dart';
|
||||
import 'package:PiliPlus/services/account_service.dart';
|
||||
import 'package:PiliPlus/utils/extension/get_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/iterable_ext.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -25,25 +20,15 @@ class MainController extends GetxController
|
||||
@override
|
||||
final AccountService accountService = Get.find<AccountService>();
|
||||
|
||||
List<NavigationBarType> navigationBars = <NavigationBarType>[];
|
||||
|
||||
RxDouble? barOffset;
|
||||
RxBool? showBottomBar;
|
||||
late final bool hideBottomBar;
|
||||
late final barHideType = Pref.barHideType;
|
||||
bool useBottomNav = false;
|
||||
late PageController controller;
|
||||
final RxInt selectedIndex = 0.obs;
|
||||
|
||||
final RxInt dynCount = 0.obs;
|
||||
late DynamicBadgeMode dynamicBadgeMode;
|
||||
late bool checkDynamic = Pref.checkDynamic;
|
||||
late int dynamicPeriod = Pref.dynamicPeriod * 60 * 1000;
|
||||
late int _lastCheckDynamicAt = 0;
|
||||
late bool hasDyn = false;
|
||||
late final dynamicController = Get.putOrFind(DynamicsController.new);
|
||||
|
||||
late bool hasHome = false;
|
||||
late final homeController = Get.putOrFind(HomeController.new);
|
||||
|
||||
late DynamicBadgeMode msgBadgeMode = Pref.msgBadgeMode;
|
||||
@@ -53,92 +38,58 @@ class MainController extends GetxController
|
||||
|
||||
final floatingNavBar = Pref.floatingNavBar;
|
||||
|
||||
late bool directExitOnBack = Pref.directExitOnBack;
|
||||
late bool showTrayIcon = Pref.showTrayIcon;
|
||||
late bool minimizeOnExit = Pref.minimizeOnExit;
|
||||
late bool pauseOnMinimize = Pref.pauseOnMinimize;
|
||||
late bool isPlaying = false;
|
||||
|
||||
static const _period = 5 * 60 * 1000;
|
||||
static const _dynamicPeriod = 5 * 60 * 1000;
|
||||
late int _lastSelectTime = 0;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
setNavBarConfig();
|
||||
|
||||
controller = PageController(initialPage: selectedIndex.value);
|
||||
|
||||
hideBottomBar = navigationBars.length > 1 && Pref.hideBottomBar;
|
||||
if (hideBottomBar) {
|
||||
switch (barHideType) {
|
||||
case .instant:
|
||||
showBottomBar = RxBool(true);
|
||||
case .sync:
|
||||
barOffset ??= RxDouble(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
dynamicBadgeMode = Pref.dynamicBadgeMode;
|
||||
|
||||
hasDyn = navigationBars.contains(NavigationBarType.dynamics);
|
||||
if (dynamicBadgeMode != DynamicBadgeMode.hidden) {
|
||||
if (hasDyn) {
|
||||
if (checkDynamic) {
|
||||
_lastCheckDynamicAt = DateTime.now().millisecondsSinceEpoch;
|
||||
}
|
||||
getUnreadDynamic();
|
||||
}
|
||||
if (dynamicBadgeMode != .hidden) {
|
||||
_lastCheckDynamicAt = DateTime.now().millisecondsSinceEpoch;
|
||||
getUnreadDynamic();
|
||||
}
|
||||
|
||||
hasHome = navigationBars.contains(NavigationBarType.home);
|
||||
if (msgBadgeMode != DynamicBadgeMode.hidden) {
|
||||
if (hasHome) {
|
||||
lastCheckUnreadAt = DateTime.now().millisecondsSinceEpoch;
|
||||
queryUnreadMsg();
|
||||
}
|
||||
if (msgBadgeMode != .hidden) {
|
||||
lastCheckUnreadAt = DateTime.now().millisecondsSinceEpoch;
|
||||
queryUnreadMsg();
|
||||
}
|
||||
}
|
||||
|
||||
Future<int> _msgUnread() async {
|
||||
if (msgUnReadTypes.contains(MsgUnReadType.pm)) {
|
||||
final res = await MsgHttp.msgUnread();
|
||||
if (res case Success(:final response)) {
|
||||
return response.followUnread +
|
||||
response.unfollowUnread +
|
||||
response.bizMsgFollowUnread +
|
||||
response.bizMsgUnfollowUnread +
|
||||
response.unfollowPushMsg +
|
||||
response.customUnread;
|
||||
}
|
||||
final res = await MsgHttp.msgUnread();
|
||||
if (res case Success(:final response)) {
|
||||
return response.followUnread +
|
||||
response.unfollowUnread +
|
||||
response.bizMsgFollowUnread +
|
||||
response.bizMsgUnfollowUnread +
|
||||
response.unfollowPushMsg +
|
||||
response.customUnread;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Future<int> _msgFeedUnread() async {
|
||||
int count = 0;
|
||||
final remainTypes = Set<MsgUnReadType>.from(msgUnReadTypes)
|
||||
..remove(MsgUnReadType.pm);
|
||||
if (remainTypes.isNotEmpty) {
|
||||
final res = await MsgHttp.msgFeedUnread();
|
||||
if (res case Success(:final response)) {
|
||||
for (final item in remainTypes) {
|
||||
switch (item) {
|
||||
case MsgUnReadType.pm:
|
||||
break;
|
||||
case MsgUnReadType.reply:
|
||||
count += response.reply;
|
||||
break;
|
||||
case MsgUnReadType.at:
|
||||
count += response.at;
|
||||
break;
|
||||
case MsgUnReadType.like:
|
||||
count += response.like;
|
||||
break;
|
||||
case MsgUnReadType.sysMsg:
|
||||
count += response.sysMsg;
|
||||
break;
|
||||
}
|
||||
final res = await MsgHttp.msgFeedUnread();
|
||||
if (res case Success(:final response)) {
|
||||
for (final item in msgUnReadTypes) {
|
||||
switch (item) {
|
||||
case .pm:
|
||||
continue;
|
||||
case .reply:
|
||||
count += response.reply;
|
||||
case .at:
|
||||
count += response.at;
|
||||
case .like:
|
||||
count += response.like;
|
||||
break;
|
||||
case .sysMsg:
|
||||
count += response.sysMsg;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,17 +98,18 @@ class MainController extends GetxController
|
||||
|
||||
Future<void> queryUnreadMsg([bool isChangeType = false]) async {
|
||||
if (!accountService.isLogin.value ||
|
||||
!hasHome ||
|
||||
msgUnReadTypes.isEmpty ||
|
||||
msgBadgeMode == DynamicBadgeMode.hidden) {
|
||||
msgBadgeMode == .hidden) {
|
||||
msgUnReadCount.value = '';
|
||||
return;
|
||||
}
|
||||
|
||||
final res = await Future.wait([_msgUnread(), _msgFeedUnread()]);
|
||||
|
||||
final hasPm = msgUnReadTypes.contains(MsgUnReadType.pm);
|
||||
final res = await Future.wait([
|
||||
if (hasPm) _msgUnread(),
|
||||
if (!(hasPm && msgUnReadTypes.length == 1)) _msgFeedUnread(),
|
||||
]);
|
||||
final count = res.sum;
|
||||
|
||||
final countStr = count == 0
|
||||
? ''
|
||||
: count > 99
|
||||
@@ -173,7 +125,7 @@ class MainController extends GetxController
|
||||
}
|
||||
|
||||
void getUnreadDynamic() {
|
||||
if (!accountService.isLogin.value || !hasDyn) {
|
||||
if (!accountService.isLogin.value) {
|
||||
return;
|
||||
}
|
||||
DynGrpc.dynRed().then((res) {
|
||||
@@ -184,74 +136,36 @@ class MainController extends GetxController
|
||||
}
|
||||
|
||||
void setDynCount([int count = 0]) {
|
||||
if (!hasDyn) return;
|
||||
dynCount.value = count;
|
||||
}
|
||||
|
||||
void checkUnreadDynamic() {
|
||||
if (!hasDyn ||
|
||||
!accountService.isLogin.value ||
|
||||
dynamicBadgeMode == DynamicBadgeMode.hidden ||
|
||||
!checkDynamic) {
|
||||
if (!accountService.isLogin.value || dynamicBadgeMode == .hidden) {
|
||||
return;
|
||||
}
|
||||
int now = DateTime.now().millisecondsSinceEpoch;
|
||||
if (now - _lastCheckDynamicAt >= dynamicPeriod) {
|
||||
if (now - _lastCheckDynamicAt >= _dynamicPeriod) {
|
||||
_lastCheckDynamicAt = now;
|
||||
getUnreadDynamic();
|
||||
}
|
||||
}
|
||||
|
||||
void setNavBarConfig() {
|
||||
List<int>? navBarSort =
|
||||
(GStorage.setting.get(SettingBoxKey.navBarSort) as List?)?.fromCast();
|
||||
late final List<NavigationBarType> navigationBars;
|
||||
if (navBarSort == null || navBarSort.isEmpty) {
|
||||
navigationBars = NavigationBarType.values;
|
||||
} else {
|
||||
navigationBars = navBarSort
|
||||
.map((i) => NavigationBarType.values[i])
|
||||
.toList();
|
||||
}
|
||||
this.navigationBars = navigationBars;
|
||||
selectedIndex.value = Pref.defaultHomePageIndex;
|
||||
}
|
||||
|
||||
void checkUnread([bool shouldCheck = false]) {
|
||||
if (accountService.isLogin.value &&
|
||||
hasHome &&
|
||||
msgBadgeMode != DynamicBadgeMode.hidden) {
|
||||
if (shouldCheck &&
|
||||
navigationBars[selectedIndex.value] != NavigationBarType.home) {
|
||||
return;
|
||||
}
|
||||
void checkUnread() {
|
||||
if (accountService.isLogin.value && msgBadgeMode != .hidden) {
|
||||
int now = DateTime.now().millisecondsSinceEpoch;
|
||||
if (now - lastCheckUnreadAt >= _period) {
|
||||
if (now - lastCheckUnreadAt >= _dynamicPeriod) {
|
||||
lastCheckUnreadAt = now;
|
||||
queryUnreadMsg();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int? _mineIndex;
|
||||
void toMinePage() {
|
||||
_mineIndex ??= navigationBars.indexOf(NavigationBarType.mine);
|
||||
if (_mineIndex != -1) {
|
||||
setIndex(_mineIndex!);
|
||||
} else {
|
||||
Get.to(
|
||||
const Material(
|
||||
child: ViewSafeArea(
|
||||
top: true,
|
||||
child: MinePage(showBackBtn: true),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
setIndex(NavigationBarType.mine.index);
|
||||
}
|
||||
|
||||
void setIndex(int value) {
|
||||
final currentNav = navigationBars[value];
|
||||
final currentNav = NavigationBarType.values[value];
|
||||
if (value != selectedIndex.value) {
|
||||
selectedIndex.value = value;
|
||||
controller.jumpToPage(value);
|
||||
@@ -279,15 +193,8 @@ class MainController extends GetxController
|
||||
}
|
||||
}
|
||||
|
||||
void setSearchBar() {
|
||||
if (hasHome) {
|
||||
homeController.showTopBar?.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
barOffset?.close();
|
||||
controller.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@@ -2,15 +2,14 @@ import 'dart:io';
|
||||
|
||||
import 'package:PiliPlus/common/assets.dart';
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/style.dart';
|
||||
import 'package:PiliPlus/common/widgets/floating_navigation_bar.dart';
|
||||
import 'package:PiliPlus/common/widgets/flutter/pop_scope.dart';
|
||||
import 'package:PiliPlus/common/widgets/route_aware_mixin.dart';
|
||||
import 'package:PiliPlus/common/widgets/scaffold.dart';
|
||||
import 'package:PiliPlus/models/common/nav_bar_config.dart';
|
||||
import 'package:PiliPlus/pages/home/view.dart';
|
||||
import 'package:PiliPlus/pages/main/controller.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/play_status.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
import 'package:PiliPlus/utils/extension/context_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/size_ext.dart';
|
||||
@@ -56,10 +55,8 @@ class _MainAppState extends PopScopeState<MainApp>
|
||||
windowManager
|
||||
..addListener(this)
|
||||
..setPreventClose(true);
|
||||
if (_mainController.showTrayIcon) {
|
||||
trayManager.addListener(this);
|
||||
_handleTray();
|
||||
}
|
||||
trayManager.addListener(this);
|
||||
_handleTray();
|
||||
} else {
|
||||
// FlutterSmartDialog throws
|
||||
PiliScheme.init();
|
||||
@@ -82,7 +79,7 @@ class _MainAppState extends PopScopeState<MainApp>
|
||||
addObserverMobile(this);
|
||||
_mainController
|
||||
..checkUnreadDynamic()
|
||||
..checkUnread(_mainController.useBottomNav);
|
||||
..checkUnread();
|
||||
super.didPopNext();
|
||||
}
|
||||
|
||||
@@ -97,7 +94,7 @@ class _MainAppState extends PopScopeState<MainApp>
|
||||
if (state == .resumed) {
|
||||
_mainController
|
||||
..checkUnreadDynamic()
|
||||
..checkUnread(_mainController.useBottomNav);
|
||||
..checkUnread();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,12 +143,7 @@ class _MainAppState extends PopScopeState<MainApp>
|
||||
|
||||
@override
|
||||
void onWindowClose() {
|
||||
if (_mainController.showTrayIcon && _mainController.minimizeOnExit) {
|
||||
windowManager.hide();
|
||||
_onHideWindow();
|
||||
} else {
|
||||
_onClose();
|
||||
}
|
||||
windowManager.hide();
|
||||
}
|
||||
|
||||
Future<void> _onClose() async {
|
||||
@@ -165,41 +157,11 @@ class _MainAppState extends PopScopeState<MainApp>
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowMinimize() {
|
||||
_onHideWindow();
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowRestore() {
|
||||
_onShowWindow();
|
||||
}
|
||||
|
||||
void _onHideWindow() {
|
||||
if (_mainController.pauseOnMinimize) {
|
||||
if (PlPlayerController.instance case final player?) {
|
||||
if (_mainController.isPlaying = player.playerStatus.isPlaying) {
|
||||
player.pause();
|
||||
}
|
||||
} else {
|
||||
_mainController.isPlaying = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _onShowWindow() {
|
||||
if (_mainController.pauseOnMinimize && _mainController.isPlaying) {
|
||||
PlPlayerController.instance?.play();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onTrayIconMouseDown() async {
|
||||
if (await windowManager.isVisible()) {
|
||||
_onHideWindow();
|
||||
windowManager.hide();
|
||||
} else {
|
||||
_onShowWindow();
|
||||
windowManager.show();
|
||||
}
|
||||
}
|
||||
@@ -248,151 +210,107 @@ class _MainAppState extends PopScopeState<MainApp>
|
||||
|
||||
@override
|
||||
void onPopInvokedWithResult(bool didPop, Object? result) {
|
||||
if (_mainController.directExitOnBack) {
|
||||
_onBack();
|
||||
if (_mainController.selectedIndex.value != 0) {
|
||||
_mainController.setIndex(0);
|
||||
} else {
|
||||
if (_mainController.selectedIndex.value != 0) {
|
||||
_mainController
|
||||
..setIndex(0)
|
||||
..barOffset?.value = 0.0
|
||||
..showBottomBar?.value = true
|
||||
..setSearchBar();
|
||||
} else {
|
||||
_onBack();
|
||||
}
|
||||
_onBack();
|
||||
}
|
||||
}
|
||||
|
||||
Widget? get _bottomNav {
|
||||
Widget? bottomNav;
|
||||
if (_mainController.navigationBars.length > 1) {
|
||||
if (_mainController.floatingNavBar) {
|
||||
bottomNav = Obx(
|
||||
() => FloatingNavigationBar(
|
||||
onDestinationSelected: _mainController.setIndex,
|
||||
selectedIndex: _mainController.selectedIndex.value,
|
||||
destinations: _mainController.navigationBars
|
||||
.map(
|
||||
(e) => FloatingNavigationDestination(
|
||||
label: e.label,
|
||||
icon: _buildIcon(type: e),
|
||||
selectedIcon: _buildIcon(type: e, selected: true),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
bottomNav = Obx(
|
||||
() => NavigationBar(
|
||||
maintainBottomViewPadding: true,
|
||||
onDestinationSelected: _mainController.setIndex,
|
||||
selectedIndex: _mainController.selectedIndex.value,
|
||||
destinations: _mainController.navigationBars
|
||||
.map(
|
||||
(e) => NavigationDestination(
|
||||
label: e.label,
|
||||
icon: _buildIcon(type: e),
|
||||
selectedIcon: _buildIcon(type: e, selected: true),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (_mainController.hideBottomBar) {
|
||||
if (_mainController.barOffset case final barOffset?) {
|
||||
return Obx(
|
||||
() => FractionalTranslation(
|
||||
translation: Offset(
|
||||
0.0,
|
||||
barOffset.value / Style.topBarHeight,
|
||||
),
|
||||
child: bottomNav,
|
||||
),
|
||||
);
|
||||
}
|
||||
if (_mainController.showBottomBar case final showBottomBar?) {
|
||||
return Obx(
|
||||
() => AnimatedSlide(
|
||||
curve: Curves.easeInOutCubicEmphasized,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
offset: Offset(0, showBottomBar.value ? 0 : 1),
|
||||
child: bottomNav,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
if (_mainController.floatingNavBar) {
|
||||
return Obx(
|
||||
() => FloatingNavigationBar(
|
||||
onDestinationSelected: _mainController.setIndex,
|
||||
selectedIndex: _mainController.selectedIndex.value,
|
||||
destinations: NavigationBarType.values
|
||||
.map(
|
||||
(e) => FloatingNavigationDestination(
|
||||
label: e.label,
|
||||
icon: _buildIcon(type: e),
|
||||
selectedIcon: _buildIcon(type: e, selected: true),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return bottomNav;
|
||||
return Obx(
|
||||
() => NavigationBar(
|
||||
maintainBottomViewPadding: true,
|
||||
onDestinationSelected: _mainController.setIndex,
|
||||
selectedIndex: _mainController.selectedIndex.value,
|
||||
destinations: NavigationBarType.values
|
||||
.map(
|
||||
(e) => NavigationDestination(
|
||||
label: e.label,
|
||||
icon: _buildIcon(type: e),
|
||||
selectedIcon: _buildIcon(type: e, selected: true),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _sideBar(ThemeData theme) {
|
||||
return _mainController.navigationBars.length > 1
|
||||
? context.isTablet
|
||||
? Column(
|
||||
children: [
|
||||
const SizedBox(height: 25),
|
||||
userAndSearchVertical(theme),
|
||||
const Spacer(flex: 2),
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: SizedBox(
|
||||
width: 130,
|
||||
child: Obx(
|
||||
() => NavigationDrawer(
|
||||
backgroundColor: Colors.transparent,
|
||||
tilePadding: const .symmetric(
|
||||
vertical: 5,
|
||||
horizontal: 12,
|
||||
),
|
||||
indicatorShape: const RoundedRectangleBorder(
|
||||
borderRadius: .all(.circular(16)),
|
||||
),
|
||||
onDestinationSelected: _mainController.setIndex,
|
||||
selectedIndex: _mainController.selectedIndex.value,
|
||||
children: _mainController.navigationBars
|
||||
.map(
|
||||
(e) => NavigationDrawerDestination(
|
||||
label: Text(e.label),
|
||||
icon: _buildIcon(type: e),
|
||||
selectedIcon: _buildIcon(
|
||||
type: e,
|
||||
selected: true,
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
return context.isTablet
|
||||
? Column(
|
||||
children: [
|
||||
const SizedBox(height: 25),
|
||||
userAndSearchVertical(theme),
|
||||
const Spacer(flex: 2),
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: SizedBox(
|
||||
width: 130,
|
||||
child: Obx(
|
||||
() => NavigationDrawer(
|
||||
backgroundColor: Colors.transparent,
|
||||
tilePadding: const .symmetric(
|
||||
vertical: 5,
|
||||
horizontal: 12,
|
||||
),
|
||||
indicatorShape: const RoundedRectangleBorder(
|
||||
borderRadius: .all(.circular(16)),
|
||||
),
|
||||
onDestinationSelected: _mainController.setIndex,
|
||||
selectedIndex: _mainController.selectedIndex.value,
|
||||
children: NavigationBarType.values
|
||||
.map(
|
||||
(e) => NavigationDrawerDestination(
|
||||
label: Text(e.label),
|
||||
icon: _buildIcon(type: e),
|
||||
selectedIcon: _buildIcon(
|
||||
type: e,
|
||||
selected: true,
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Obx(
|
||||
() => NavigationRail(
|
||||
groupAlignment: 0.5,
|
||||
selectedIndex: _mainController.selectedIndex.value,
|
||||
onDestinationSelected: _mainController.setIndex,
|
||||
labelType: .selected,
|
||||
leading: userAndSearchVertical(theme),
|
||||
destinations: _mainController.navigationBars
|
||||
.map(
|
||||
(e) => NavigationRailDestination(
|
||||
label: Text(e.label),
|
||||
icon: _buildIcon(type: e),
|
||||
selectedIcon: _buildIcon(type: e, selected: true),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
width: 80,
|
||||
padding: const .only(top: 10),
|
||||
child: userAndSearchVertical(theme),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Obx(
|
||||
() => NavigationRail(
|
||||
groupAlignment: 0.5,
|
||||
selectedIndex: _mainController.selectedIndex.value,
|
||||
onDestinationSelected: _mainController.setIndex,
|
||||
labelType: .selected,
|
||||
leading: userAndSearchVertical(theme),
|
||||
destinations: NavigationBarType.values
|
||||
.map(
|
||||
(e) => NavigationRailDestination(
|
||||
label: Text(e.label),
|
||||
icon: _buildIcon(type: e),
|
||||
selectedIcon: _buildIcon(type: e, selected: true),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -401,7 +319,7 @@ class _MainAppState extends PopScopeState<MainApp>
|
||||
Widget child = PageView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
controller: _mainController.controller,
|
||||
children: _mainController.navigationBars.map((i) => i.page).toList(),
|
||||
children: NavigationBarType.values.map((i) => i.page).toList(),
|
||||
);
|
||||
|
||||
Widget? bottomNav;
|
||||
@@ -422,18 +340,36 @@ class _MainAppState extends PopScopeState<MainApp>
|
||||
);
|
||||
}
|
||||
|
||||
child = Scaffold(
|
||||
extendBody: true,
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: AppBar(toolbarHeight: 0),
|
||||
body: Padding(
|
||||
padding: .only(
|
||||
left: _mainController.useBottomNav ? _padding.left : 0.0,
|
||||
right: _padding.right,
|
||||
),
|
||||
child: child,
|
||||
child = Padding(
|
||||
padding: .only(
|
||||
left: _mainController.useBottomNav ? _padding.left : 0.0,
|
||||
right: _padding.right,
|
||||
),
|
||||
bottomNavigationBar: bottomNav,
|
||||
child: child,
|
||||
);
|
||||
|
||||
child = scaffold(
|
||||
appBar: AppBar(toolbarHeight: 0),
|
||||
body: _mainController.floatingNavBar
|
||||
? Stack(
|
||||
clipBehavior: .none,
|
||||
children: [
|
||||
child,
|
||||
if (bottomNav != null)
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: bottomNav,
|
||||
),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
Expanded(child: child),
|
||||
?bottomNav,
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (PlatformUtils.isMobile) {
|
||||
|
||||
Reference in New Issue
Block a user