forked from lxm_flutter/FlutterUnit
优化配色,优化左右菜单栏弹出方案
This commit is contained in:
11
README.md
11
README.md
@@ -188,3 +188,14 @@ fixed " 主页item双击黑屏问题。
|
||||
feature " 支持详情页【相关链接的栈管理】,
|
||||
" 即: 点击多个链接,不直接返回主页.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
- `2020-4-28`
|
||||
|
||||
```
|
||||
feature " 小彩蛋: 【长按】底部栏【最左侧按钮】,打开左边菜单栏
|
||||
" 【长按】底部栏【最右侧按钮】,打开右边菜单栏
|
||||
|
||||
fixed " 收藏集的AppBar背景色同主页选中色。
|
||||
```
|
||||
@@ -6,6 +6,7 @@ import 'package:flutter_unit/blocs/collect/collect_event.dart';
|
||||
import 'package:flutter_unit/blocs/collect/collect_state.dart';
|
||||
import 'package:flutter_unit/blocs/detail/detail_bloc.dart';
|
||||
import 'package:flutter_unit/blocs/detail/detail_event.dart';
|
||||
import 'package:flutter_unit/blocs/widgets/home_bloc.dart';
|
||||
import 'package:flutter_unit/model/widget_model.dart';
|
||||
import 'package:flutter_unit/views/items/collect_widget_list_item.dart';
|
||||
|
||||
@@ -24,6 +25,7 @@ class CollectPage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: BlocProvider.of<HomeBloc>(context).state.homeColor,
|
||||
title: Text('收藏集'),
|
||||
actions: <Widget>[
|
||||
IconButton(icon: Icon(Icons.add,size: 30,), onPressed: (){
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
/// create by 张风捷特烈 on 2020-04-11
|
||||
/// contact me by email 1981462002@qq.com
|
||||
/// 说明:
|
||||
/// 说明:
|
||||
|
||||
class UnitBottomBar extends StatefulWidget {
|
||||
final Color color;
|
||||
@@ -11,8 +11,8 @@ class UnitBottomBar extends StatefulWidget {
|
||||
|
||||
UnitBottomBar(
|
||||
{this.color = Colors.blue,
|
||||
@required this.itemData,
|
||||
@required this.onItemClick});
|
||||
@required this.itemData,
|
||||
@required this.onItemClick});
|
||||
|
||||
@override
|
||||
_UnitBottomBarState createState() => _UnitBottomBarState();
|
||||
@@ -30,24 +30,20 @@ class _UnitBottomBarState extends State<UnitBottomBar> {
|
||||
color: widget.color,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: widget.itemData.keys
|
||||
.map((e) => _buildChild(info.indexOf(e), widget.color))
|
||||
children: info
|
||||
.map((e) => _buildChild(context, info.indexOf(e), widget.color))
|
||||
.toList(),
|
||||
));
|
||||
}
|
||||
|
||||
List<String> get info => widget.itemData.keys.toList();
|
||||
|
||||
Widget _buildChild(int i, Color color) {
|
||||
Widget _buildChild(BuildContext context, int i, Color color) {
|
||||
var active = i == _position;
|
||||
bool left = i == 0;
|
||||
return GestureDetector(
|
||||
onTap: () => setState(() {
|
||||
_position = i;
|
||||
if (widget.onItemClick != null) {
|
||||
widget.onItemClick(_position);
|
||||
}
|
||||
}),
|
||||
onTap: () => _tapTab(i),
|
||||
onLongPress: () => _onLongPress(context, i),
|
||||
child: Material(
|
||||
elevation: 2,
|
||||
shape: RoundedRectangleBorder(
|
||||
@@ -74,4 +70,22 @@ class _UnitBottomBarState extends State<UnitBottomBar> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_tapTab(int i) {
|
||||
setState(() {
|
||||
_position = i;
|
||||
if (widget.onItemClick != null) {
|
||||
widget.onItemClick(_position);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_onLongPress(BuildContext context, int i) {
|
||||
if (i == 0) {
|
||||
Scaffold.of(context).openDrawer();
|
||||
}
|
||||
if (i == 1) {
|
||||
Scaffold.of(context).openEndDrawer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ import 'package:flutter_unit/app/res/cons.dart';
|
||||
import 'package:flutter_unit/app/router.dart';
|
||||
import 'package:flutter_unit/blocs/collect/collect_bloc.dart';
|
||||
import 'package:flutter_unit/blocs/collect/collect_event.dart';
|
||||
import 'package:flutter_unit/blocs/global/global_bloc.dart';
|
||||
import 'package:flutter_unit/blocs/global/global_state.dart';
|
||||
import 'package:flutter_unit/blocs/widgets/home_bloc.dart';
|
||||
import 'package:flutter_unit/blocs/widgets/home_state.dart';
|
||||
import 'package:flutter_unit/views/pages/navigation/unit_bottom_bar.dart';
|
||||
@@ -36,19 +34,14 @@ class _UnitNavigationState extends State<UnitNavigation> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<HomeBloc, HomeState>(
|
||||
builder: (_, state) =>
|
||||
Scaffold(
|
||||
builder: (_, state) => Scaffold(
|
||||
drawer: HomeDrawer(),
|
||||
//左滑页
|
||||
endDrawer: HomeDrawer(),
|
||||
//右滑页
|
||||
floatingActionButtonLocation:
|
||||
FloatingActionButtonLocation.centerDocked,
|
||||
floatingActionButton: FloatingActionButton(
|
||||
backgroundColor: state.homeColor,
|
||||
child: Icon(Icons.search),
|
||||
onPressed: () => Navigator.of(context).pushNamed(Router.search),
|
||||
),
|
||||
floatingActionButton: _buildSearchButton(state.homeColor),
|
||||
body: PageView(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
//使用PageView实现页面的切换
|
||||
@@ -61,9 +54,16 @@ class _UnitNavigationState extends State<UnitNavigation> {
|
||||
bottomNavigationBar: UnitBottomBar(
|
||||
color: state.homeColor,
|
||||
itemData: Cons.ICONS_MAP,
|
||||
onItemClick: _onTapNav)
|
||||
)
|
||||
);
|
||||
onItemClick: _onTapNav)));
|
||||
}
|
||||
|
||||
Widget _buildSearchButton(Color color) {
|
||||
return Builder(
|
||||
builder: (context) => FloatingActionButton(
|
||||
backgroundColor: color,
|
||||
child: Icon(Icons.search),
|
||||
onPressed: () => Navigator.of(context).pushNamed(Router.search),
|
||||
));
|
||||
}
|
||||
|
||||
_onTapNav(int index) {
|
||||
@@ -74,4 +74,3 @@ class _UnitNavigationState extends State<UnitNavigation> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user