11import 'package:flutter/material.dart' ;
2+ import 'package:flutter_unit/app/res/size_unit.dart' ;
23import 'package:flutter_unit/app/res/toly_icon.dart' ;
34import 'package:flutter_unit/components/permanent/feedback_widget.dart' ;
45
@@ -8,12 +9,10 @@ import 'package:flutter_unit/components/permanent/feedback_widget.dart';
89
910class UnitBottomBar extends StatefulWidget {
1011 final Color color;
11- final Map <String , IconData > itemData;
1212 final Function (int ) onItemClick;
1313
1414 UnitBottomBar (
1515 {this .color = Colors .blue,
16- @required this .itemData,
1716 @required this .onItemClick});
1817
1918 @override
@@ -25,6 +24,16 @@ class _UnitBottomBarState extends State<UnitBottomBar> {
2524
2625 final NotchedShape shape = const CircularNotchedRectangle ();
2726
27+ final borderTR = const BorderRadius .only (
28+ topRight: Radius .circular (10 ),
29+ );
30+
31+ final borderTL = const BorderRadius .only (topLeft: Radius .circular (10 ));
32+ final paddingTR = const EdgeInsets .only (top: 2 , right: 2 );
33+ final paddingTL = const EdgeInsets .only (top: 2 , left: 2 );
34+ final paddingL = const EdgeInsets .only (left: 8 );
35+ final paddingR = const EdgeInsets .only (right: 8 );
36+
2837 @override
2938 Widget build (BuildContext context) {
3039 return BottomAppBar (
@@ -36,117 +45,117 @@ class _UnitBottomBarState extends State<UnitBottomBar> {
3645 data: IconTheme .of (context).copyWith (color: Colors .white, size: 25 ),
3746 child: Stack (
3847 children: [
39- Material (
40- elevation: 0 ,
41- shape: RoundedRectangleBorder (borderRadius: borderTR),
42- child: Container (
43- margin: paddingTR,
44- alignment: Alignment .center,
45- decoration: BoxDecoration (
46- color: widget.color.withAlpha (88 ),
47- borderRadius: borderTR),
48- height: 50 ,
49- width: 120 ,
50- child: Row (
51- mainAxisAlignment: MainAxisAlignment .center,
52- children: [
53- FeedbackWidget (
54- onPressed: () => _updateIndex (0 ),
55- onLongPressed: () => _onLongPress (context, 0 ),
56- child: Container (
57- width: 50 ,
58- height: 50 ,
59- child: Icon (
60- TolyIcon .icon_layout,
61- size: _position == 0 ? 28 : 25 ,
62- color:
63- _position == 0 ? widget.color : Colors .white,
64- )),
65- ),
66- FeedbackWidget (
67- onPressed: () => _updateIndex (1 ),
68- child: Container (
69- width: 50 ,
70- height: 50 ,
71- child: Icon (
72- TolyIcon .kujialeqiyezhan_tiaosepan,
73- size: _position == 1 ? 28 : 25 ,
74- color:
75- _position == 1 ? widget.color : Colors .white,
76- )),
77- ),
78- ],
79- ),
80- ),
81- ),
48+ _buildLeftBtn (context),
8249 Positioned (
8350 right: 0 ,
84- child: Material (
85- elevation: 0 ,
86- shape: RoundedRectangleBorder (borderRadius: borderTL),
87- child: Container (
88- margin: paddingTL,
89- alignment: Alignment .center,
90- decoration: BoxDecoration (
91- color: widget.color.withAlpha (88 ),
92- borderRadius: borderTL),
93- height: 50 ,
94- width: 120 ,
95- child: Row (
96- mainAxisAlignment: MainAxisAlignment .center,
97- children: [
98- FeedbackWidget (
99- onPressed: () => _updateIndex (2 ),
100- child: Container (
101- width: 50 ,
102- height: 50 ,
103- child: Icon (
104- TolyIcon .icon_collect,
105- size: _position == 2 ? 28 : 25 ,
106- color: _position == 2
107- ? widget.color
108- : Colors .white,
109- )),
110- ),
111- FeedbackWidget (
112- onPressed: () => _updateIndex (3 ),
113- onLongPressed: () => _onLongPress (context, 1 ),
114- child: Container (
115- width: 50 ,
116- height: 50 ,
117- child: Icon (
118- TolyIcon .yonghu,
119- size: _position == 3 ? 28 : 25 ,
120- color: _position == 3
121- ? widget.color
122- : Colors .white,
123- )),
124- ),
125- ],
126- ),
127- ),
128- ),
51+ child: _buildRightBtn (context),
12952 ),
13053 ],
13154 ),
13255 ));
13356 }
13457
58+ Widget _buildLeftBtn (BuildContext context) => Material (
59+ shape: RoundedRectangleBorder (borderRadius: borderTR),
60+ child: Container (
61+ margin: paddingTR,
62+ alignment: Alignment .center,
63+ decoration: BoxDecoration (
64+ color: widget.color.withAlpha (88 ), borderRadius: borderTR),
65+ height: SizeUnit .bottom_nav_height,
66+ width: SizeUnit .bottom_nav_right_width,
67+ child: Row (
68+ mainAxisAlignment: MainAxisAlignment .center,
69+ children: [
70+ Expanded (
71+ child: FeedbackWidget (
72+ onPressed: () => _updateIndex (0 ),
73+ onLongPressed: () => _onLongPress (context, 0 ),
74+ child: Container (
75+ padding: paddingL,
76+ height: SizeUnit .bottom_nav_height,
77+ child: Icon (
78+ TolyIcon .icon_layout,
79+ size: iconSize (0 ),
80+ color: iconColor (0 ),
81+ )),
82+ ),
83+ ),
84+ Expanded (
85+ child: FeedbackWidget (
86+ onPressed: () => _updateIndex (1 ),
87+ child: Container (
88+ height: SizeUnit .bottom_nav_height,
89+ padding: paddingR,
90+ child: Icon (
91+ TolyIcon .dingzhi1,
92+ size: iconSize (1 ),
93+ color: iconColor (1 ),
94+ )),
95+ ),
96+ ),
97+ ],
98+ ),
99+ ),
100+ );
101+
102+ Widget _buildRightBtn (BuildContext context) => Material (
103+ shape: RoundedRectangleBorder (borderRadius: borderTL),
104+ child: Container (
105+ margin: paddingTL,
106+ alignment: Alignment .center,
107+ decoration: BoxDecoration (
108+ color: widget.color.withAlpha (88 ), borderRadius: borderTL),
109+ height: SizeUnit .bottom_nav_height,
110+ width: SizeUnit .bottom_nav_right_width,
111+ child: Row (
112+ mainAxisAlignment: MainAxisAlignment .center,
113+ children: [
114+ Expanded (
115+ child: FeedbackWidget (
116+ onPressed: () => _updateIndex (2 ),
117+ child: Container (
118+ padding: paddingL,
119+ height: SizeUnit .bottom_nav_height,
120+ child: Icon (
121+ TolyIcon .icon_collect,
122+ size: iconSize (2 ),
123+ color: iconColor (2 ),
124+ )),
125+ ),
126+ ),
127+ Expanded (
128+ child: FeedbackWidget (
129+ onPressed: () => _updateIndex (3 ),
130+ onLongPressed: () => _onLongPress (context, 1 ),
131+ child: Container (
132+ padding: paddingR,
133+ height: SizeUnit .bottom_nav_height,
134+ child: Icon (
135+ TolyIcon .yonghu,
136+ size: iconSize (3 ),
137+ color: iconColor (3 ),
138+ )),
139+ ),
140+ ),
141+ ],
142+ ),
143+ ),
144+ );
145+
146+ double iconSize (int position) => _position == position
147+ ? SizeUnit .active_bottom_nav_icon
148+ : SizeUnit .default_bottom_nav_icon;
149+
150+ Color iconColor (int position) =>
151+ _position == position ? widget.color : Colors .white;
152+
135153 void _updateIndex (int index) {
136154 setState (() {
137155 _position = index;
138156 widget.onItemClick (_position);
139157 });
140158 }
141-
142- List <String > get info => widget.itemData.keys.toList ();
143-
144- final borderTR = const BorderRadius .only (
145- topRight: Radius .circular (10 ),
146- );
147- final borderTL = const BorderRadius .only (topLeft: Radius .circular (10 ));
148- final paddingTR = const EdgeInsets .only (top: 2 , right: 2 );
149- final paddingTL = const EdgeInsets .only (top: 2 , left: 2 );
150159}
151160
152161_onLongPress (BuildContext context, int i) {
0 commit comments