feat: 底栏样式 issues #189
This commit is contained in:
@ -29,6 +29,8 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
late Animation<double>? _slideAnimation;
|
late Animation<double>? _slideAnimation;
|
||||||
int selectedIndex = 0;
|
int selectedIndex = 0;
|
||||||
int? _lastSelectTime; //上次点击时间
|
int? _lastSelectTime; //上次点击时间
|
||||||
|
Box setting = GStrorage.setting;
|
||||||
|
late bool enableMYBar;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -45,6 +47,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
Tween(begin: 0.8, end: 1.0).animate(_animationController!);
|
Tween(begin: 0.8, end: 1.0).animate(_animationController!);
|
||||||
_lastSelectTime = DateTime.now().millisecondsSinceEpoch;
|
_lastSelectTime = DateTime.now().millisecondsSinceEpoch;
|
||||||
_pageController = PageController(initialPage: selectedIndex);
|
_pageController = PageController(initialPage: selectedIndex);
|
||||||
|
enableMYBar = setting.get(SettingBoxKey.enableMYBar, defaultValue: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setIndex(int value) async {
|
void setIndex(int value) async {
|
||||||
@ -144,21 +147,38 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
builder: (context, AsyncSnapshot snapshot) {
|
builder: (context, AsyncSnapshot snapshot) {
|
||||||
return AnimatedSlide(
|
return AnimatedSlide(
|
||||||
curve: Curves.easeInOutCubicEmphasized,
|
curve: Curves.easeInOutCubicEmphasized,
|
||||||
duration: const Duration(milliseconds: 1000),
|
duration: const Duration(milliseconds: 500),
|
||||||
offset: Offset(0, snapshot.data ? 0 : 1),
|
offset: Offset(0, snapshot.data ? 0 : 1),
|
||||||
child: NavigationBar(
|
child: enableMYBar
|
||||||
onDestinationSelected: (value) => setIndex(value),
|
? NavigationBar(
|
||||||
selectedIndex: selectedIndex,
|
onDestinationSelected: (value) => setIndex(value),
|
||||||
destinations: <Widget>[
|
selectedIndex: selectedIndex,
|
||||||
..._mainController.navigationBars.map((e) {
|
destinations: <Widget>[
|
||||||
return NavigationDestination(
|
..._mainController.navigationBars.map((e) {
|
||||||
icon: e['icon'],
|
return NavigationDestination(
|
||||||
selectedIcon: e['selectIcon'],
|
icon: e['icon'],
|
||||||
label: e['label'],
|
selectedIcon: e['selectIcon'],
|
||||||
);
|
label: e['label'],
|
||||||
}).toList(),
|
);
|
||||||
],
|
}).toList(),
|
||||||
),
|
],
|
||||||
|
)
|
||||||
|
: BottomNavigationBar(
|
||||||
|
currentIndex: selectedIndex,
|
||||||
|
onTap: (value) => setIndex(value),
|
||||||
|
iconSize: 16,
|
||||||
|
selectedFontSize: 12,
|
||||||
|
unselectedFontSize: 12,
|
||||||
|
items: [
|
||||||
|
..._mainController.navigationBars.map((e) {
|
||||||
|
return BottomNavigationBarItem(
|
||||||
|
icon: e['icon'],
|
||||||
|
activeIcon: e['selectIcon'],
|
||||||
|
label: e['label'],
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/models/common/theme_type.dart';
|
import 'package:pilipala/models/common/theme_type.dart';
|
||||||
@ -78,6 +77,12 @@ class _StyleSettingState extends State<StyleSetting> {
|
|||||||
setKey: SettingBoxKey.iosTransition,
|
setKey: SettingBoxKey.iosTransition,
|
||||||
defaultVal: false,
|
defaultVal: false,
|
||||||
),
|
),
|
||||||
|
const SetSwitchItem(
|
||||||
|
title: 'MD3样式底栏',
|
||||||
|
subTitle: '符合Material You设计规范的底栏',
|
||||||
|
setKey: SettingBoxKey.enableMYBar,
|
||||||
|
defaultVal: true,
|
||||||
|
),
|
||||||
// SetSwitchItem(
|
// SetSwitchItem(
|
||||||
// title: '首页单列',
|
// title: '首页单列',
|
||||||
// subTitle: '每行展示一个内容卡片',
|
// subTitle: '每行展示一个内容卡片',
|
||||||
|
|||||||
@ -135,6 +135,7 @@ class SettingBoxKey {
|
|||||||
static const String enableSingleRow = 'enableSingleRow'; // 首页单列
|
static const String enableSingleRow = 'enableSingleRow'; // 首页单列
|
||||||
static const String displayMode = 'displayMode';
|
static const String displayMode = 'displayMode';
|
||||||
static const String customRows = 'customRows'; // 自定义列
|
static const String customRows = 'customRows'; // 自定义列
|
||||||
|
static const String enableMYBar = 'enableMYBar';
|
||||||
}
|
}
|
||||||
|
|
||||||
class LocalCacheKey {
|
class LocalCacheKey {
|
||||||
|
|||||||
Reference in New Issue
Block a user