modify bottom tab

This commit is contained in:
xj.deng
2019-05-07 14:17:24 +08:00
parent a893994b47
commit 8ff0988a95
5 changed files with 61 additions and 72 deletions

View File

@ -353,7 +353,7 @@
); );
inputPaths = ( inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", "${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../.symlinks/flutter/ios-release/Flutter.framework", "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
); );
name = "[CP] Embed Pods Frameworks"; name = "[CP] Embed Pods Frameworks";
outputPaths = ( outputPaths = (

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Original</string>
</dict>
</plist>

View File

@ -1,4 +1,3 @@
/// Created with Android Studio. /// Created with Android Studio.
/// User: 三帆 /// User: 三帆
/// Date: 16/01/2019 /// Date: 16/01/2019
@ -6,7 +5,6 @@
/// email: sanfan.hx@alibaba-inc.com /// email: sanfan.hx@alibaba-inc.com
/// target: app首页 /// target: app首页
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_go/utils/shared_preferences.dart'; import 'package:flutter_go/utils/shared_preferences.dart';
@ -36,41 +34,40 @@ class _MyHomePageState extends State<AppPage>
SpUtil sp; SpUtil sp;
WidgetControlModel widgetControl = new WidgetControlModel(); WidgetControlModel widgetControl = new WidgetControlModel();
SearchHistoryList searchHistoryList; SearchHistoryList searchHistoryList;
TabController controller;
bool isSearch = false; bool isSearch = false;
String data = '';
String data2ThirdPage = '这是传给ThirdPage的值';
String appBarTitle = tabData[0]['text']; String appBarTitle = tabData[0]['text'];
List<Widget> list = List();
int _currentIndex = 0;
static List tabData = [ static List tabData = [
{'text': '业界动态', 'icon': new Icon(Icons.language)}, {'text': '业界动态', 'icon': Icon(Icons.language)},
{'text': 'WIDGET', 'icon': new Icon(Icons.extension)}, {'text': 'WIDGET', 'icon': Icon(Icons.extension)},
{'text': '组件收藏', 'icon': new Icon(Icons.favorite)}, {'text': '组件收藏', 'icon': Icon(Icons.favorite)},
{'text': '关于手册', 'icon': new Icon(Icons.import_contacts)} {'text': '关于手册', 'icon': Icon(Icons.import_contacts)}
]; ];
List<Widget> myTabs = []; List<BottomNavigationBarItem> myTabs = [];
@override @override
void initState() { void initState() {
super.initState(); super.initState();
initSearchHistory(); initSearchHistory();
controller = new TabController(
initialIndex: 0, vsync: this, length: 4); // 这里的length 决定有多少个底导 submenus
for (int i = 0; i < tabData.length; i++) { for (int i = 0; i < tabData.length; i++) {
myTabs.add(new Tab(text: tabData[i]['text'], icon: tabData[i]['icon'])); myTabs.add(BottomNavigationBarItem(
icon: tabData[i]['icon'],
title: Text(
tabData[i]['text'],
),
));
} }
controller.addListener(() { list
if (controller.indexIsChanging) { ..add(FirstPage())
_onTabChange(); ..add(WidgetPage(Provider.db))
} ..add(CollectionPage())
}); ..add(FourthPage());
Application.controller = controller;
} }
@override @override
void dispose() { void dispose() {
controller.dispose();
super.dispose(); super.dispose();
} }
@ -100,7 +97,6 @@ class _MyHomePageState extends State<AppPage>
return new SearchInput((value) async { return new SearchInput((value) async {
if (value != '') { if (value != '') {
List<WidgetPoint> list = await widgetControl.search(value); List<WidgetPoint> list = await widgetControl.search(value);
return list return list
.map((item) => new MaterialSearchResult<String>( .map((item) => new MaterialSearchResult<String>(
value: item.name, value: item.name,
@ -119,52 +115,27 @@ class _MyHomePageState extends State<AppPage>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var db = Provider.db;
return new Scaffold( return new Scaffold(
appBar: new AppBar(title: buildSearchInput(context)), appBar: new AppBar(title: buildSearchInput(context)),
body: new TabBarView(controller: controller, children: <Widget>[ body: list[_currentIndex],
new FirstPage(), bottomNavigationBar: BottomNavigationBar(
new WidgetPage(db), items: myTabs,
new CollectionPage(), //高亮 被点击高亮
FourthPage() currentIndex: _currentIndex,
]), //修改 页面
bottomNavigationBar: Material( onTap: _ItemTapped,
color: const Color(0xFFF0EEEF), //底部导航栏主题颜色 //shifting :按钮点击移动效果,超过5个button不支持
child: SafeArea( //fixed固定
child: Container( type: BottomNavigationBarType.fixed,
height: 65.0, fixedColor: Color(0xFFC91B3A),
decoration: BoxDecoration(
color: const Color(0xFFF0F0F0),
boxShadow: <BoxShadow>[
BoxShadow(
color: const Color(0xFFd0d0d0),
blurRadius: 3.0,
spreadRadius: 2.0,
offset: Offset(-1.0, -1.0),
),
],
),
child: TabBar(
controller: controller,
indicatorColor: Theme.of(context).primaryColor,
//tab标签的下划线颜色
// labelColor: const Color(0xFF000000),
indicatorWeight: 3.0,
labelColor: Theme.of(context).primaryColor,
unselectedLabelColor: const Color(0xFF8E8E8E),
tabs: myTabs),
),
),
), ),
); );
} }
void _onTabChange() { void _ItemTapped(int index) {
if (this.mounted) { setState(() {
this.setState(() { _currentIndex = index;
appBarTitle = tabData[controller.index]['text']; appBarTitle = tabData[index]['text'];
}); });
}
} }
} }

View File

@ -14,7 +14,7 @@ packages:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.2.0" version: "2.0.8"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
@ -150,7 +150,7 @@ packages:
name: matcher name: matcher
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.5" version: "0.12.3+1"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@ -171,14 +171,14 @@ packages:
name: pedantic name: pedantic
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.5.0" version: "1.4.0"
quiver: quiver:
dependency: transitive dependency: transitive
description: description:
name: quiver name: quiver
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.3" version: "2.0.1"
shared_preferences: shared_preferences:
dependency: "direct main" dependency: "direct main"
description: description:
@ -197,7 +197,7 @@ packages:
name: source_span name: source_span
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.5.5" version: "1.5.4"
sqflite: sqflite:
dependency: "direct main" dependency: "direct main"
description: description:
@ -218,7 +218,7 @@ packages:
name: stream_channel name: stream_channel
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "1.6.8"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
@ -246,7 +246,7 @@ packages:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.5" version: "0.2.2"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@ -269,5 +269,5 @@ packages:
source: hosted source: hosted
version: "2.0.8" version: "2.0.8"
sdks: sdks:
dart: ">=2.2.0 <3.0.0" dart: ">=2.1.0 <3.0.0"
flutter: ">=1.2.1 <2.0.0" flutter: ">=1.2.1 <2.0.0"