From 2fa3dfa53fe69f89fcdf3b5d5ea70bd583fa3e2b Mon Sep 17 00:00:00 2001 From: guozhigq Date: Fri, 30 Jun 2023 00:03:42 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20=E4=BF=AE=E6=94=B9bottomBar=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/main/controller.dart | 58 +++------------------------------- lib/pages/main/view.dart | 16 +++++----- pubspec.lock | 8 +++++ pubspec.yaml | 1 + 4 files changed, 21 insertions(+), 62 deletions(-) diff --git a/lib/pages/main/controller.dart b/lib/pages/main/controller.dart index 32ebfd5b..76c210ef 100644 --- a/lib/pages/main/controller.dart +++ b/lib/pages/main/controller.dart @@ -19,82 +19,32 @@ class MainController extends GetxController { ]; RxList navigationBars = [ { - // 'icon': const Icon(Icons.home_outlined), - // 'selectedIcon': const Icon(Icons.home), 'icon': const Icon( - CupertinoIcons.square_favorites_alt, - size: 21, - ), - 'selectedIcon': const Icon( - CupertinoIcons.square_favorites_alt_fill, + Icons.motion_photos_on_outlined, size: 21, ), 'label': "推荐", }, { - // 'icon': const Icon(Icons.whatshot_outlined), - // 'selectedIcon': const Icon(Icons.whatshot_rounded), 'icon': const Icon( - CupertinoIcons.flame, - size: 20, - ), - 'selectedIcon': const Icon( - CupertinoIcons.flame_fill, + Icons.eco, size: 20, ), 'label': "热门", }, { 'icon': const Icon( - CupertinoIcons.camera_on_rectangle, - size: 21, - ), - 'selectedIcon': const Icon( - CupertinoIcons.camera_on_rectangle_fill, + Icons.bolt, size: 21, ), 'label': "动态", }, { - // 'icon': const Icon(Icons.person_outline), - // 'selectedIcon': const Icon(Icons.person), 'icon': const Icon( - CupertinoIcons.folder, - size: 20, - ), - 'selectedIcon': const Icon( - CupertinoIcons.folder_fill, + Icons.folder_open_outlined, size: 20, ), 'label': "媒体库", } ].obs; - - @override - void onInit() { - super.onInit(); - // readuUserFace(); - } - - // 设置头像 - // readuUserFace() async { - // Box user = GStrorage.user; - // if (user.get(UserBoxKey.userFace) != null) { - // navigationBars.last['icon'] = - // navigationBars.last['selectedIcon'] = NetworkImgLayer( - // width: 25, - // height: 25, - // type: 'avatar', - // src: user.get(UserBoxKey.userFace), - // ); - // navigationBars.last['label'] = '我'; - // } - // } - - // 重置 - // resetLast() { - // navigationBars.last['icon'] = const Icon(Icons.person_outline); - // navigationBars.last['selectedIcon'] = const Icon(Icons.person); - // navigationBars.last['label'] = '我的'; - // } } diff --git a/lib/pages/main/view.dart b/lib/pages/main/view.dart index 9a8bab87..237e27dc 100644 --- a/lib/pages/main/view.dart +++ b/lib/pages/main/view.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:pilipala/pages/home/index.dart'; import 'package:pilipala/pages/hot/index.dart'; +import 'package:salomon_bottom_bar/salomon_bottom_bar.dart'; import './controller.dart'; class MainApp extends StatefulWidget { @@ -111,17 +112,16 @@ class _MainAppState extends State with SingleTickerProviderStateMixin { ), ), ), - bottomNavigationBar: NavigationBar( - elevation: 1, - destinations: _mainController.navigationBars.map((e) { - return NavigationDestination( + bottomNavigationBar: SalomonBottomBar( + currentIndex: selectedIndex, + onTap: (value) => setIndex(value), + items: _mainController.navigationBars.map((e) { + return SalomonBottomBarItem( icon: e['icon'], - selectedIcon: e['selectedIcon'], - label: e['label'], + title: Text(e['label']), + selectedColor: Theme.of(context).colorScheme.primary, ); }).toList(), - selectedIndex: selectedIndex, - onDestinationSelected: (value) => setIndex(value), ), ); } diff --git a/pubspec.lock b/pubspec.lock index 5376a175..bb360460 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -902,6 +902,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.2" + salomon_bottom_bar: + dependency: "direct main" + description: + name: salomon_bottom_bar + sha256: e20abf2e449749432223a8b4e6647c212eef6c2b638e0ed8cc92eff9529c2b48 + url: "https://pub.dev" + source: hosted + version: "3.3.2" screen_brightness: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 0289ae1f..c5132002 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -79,6 +79,7 @@ dependencies: url: https://github.com/guozhigq/flutter_meedu_media_kit.git ref: feature-custom path: package + salomon_bottom_bar: ^3.3.2 dev_dependencies: flutter_test: