Commit f6a8e0b6 authored by 林生雨's avatar 林生雨

commit

parent d1df55f1
......@@ -491,7 +491,7 @@ Widget askWidget() {
}
class StickyTabBarDelegate extends SliverPersistentHeaderDelegate {
final TabBar child;
final Widget child;
StickyTabBarDelegate({@required this.child});
......@@ -502,10 +502,10 @@ class StickyTabBarDelegate extends SliverPersistentHeaderDelegate {
}
@override
double get maxExtent => this.child.preferredSize.height;
double get maxExtent => 40;
@override
double get minExtent => this.child.preferredSize.height;
double get minExtent => 40;
@override
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) {
......
......@@ -8,18 +8,14 @@ import 'package:flutter_common/commonModel/live/LiveData.dart';
class TopModel extends BaseModel {
int tabIndex = 0;
List<String> tabs = ["全部", "眼部", "自体脂肪", "轮廓骨骼"];
LiveData<int> tabIndexLive = LiveData();
@override
void dispose() {
tabIndexLive.dispost();
}
void dispose() {}
void selectTab(int index) {
if (tabIndex == index) {
return;
}
tabIndex = index;
tabIndexLive.notifyView(index);
}
}
......@@ -51,51 +51,50 @@ class TopPageState extends BaseState<TopPage> with TickerProviderStateMixin {
),
SliverToBoxAdapter(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Container(
height: 50,
)
],
)),
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Container(
height: 50,
color: Colors.pink,
)
],
)),
SliverPersistentHeader(
pinned: true,
delegate: StickyTabBarDelegate(
child: baseTabBar(tabController, getTabs(), (index) {
_model.selectTab(index);
})),
child: Container(
height: 40,
color: Colors.white,
child: baseTabBar(tabController, getTabs(), (index) {
_model.selectTab(index);
}),
)),
),
SliverFillRemaining(
child: TabBarView(controller: tabController, children: <Widget>[
Container(
color: Colors.red,
),
Container(
color: Colors.red,
),
Container(
color: Colors.red,
),
Container(
color: Colors.blue,
)
]))
Container(
color: Colors.red,
),
Container(
color: Colors.red,
),
Container(
color: Colors.red,
),
Container(
color: Colors.blue,
)
]))
]));
}
List<Widget> getTabs() {
List<Widget> list = [];
for (int i = 0; i < _model.tabs.length; i++) {
list.add( Container(
height: 40,
width: 50,
color: Colors.red,
));
// list.add(baseTabBarItem(_model.tabs[i],
// leftPadding: i == 0 ? 24 : 28,
// color: i == _model.tabIndex ? Color(0xff282828) : Color(0xffB5B5B5)));
list.add(baseTabBarItem(_model.tabs[i],
leftPadding: i == 0 ? 24 : 28,
rightPadding: i == _model.tabs.length - 1 ? 24 : 28));
}
return list;
}
......
......@@ -400,12 +400,16 @@ Widget emptyItem(double width, double height, {String detail}) {
Widget baseTabBar(
TabController controller, List<Widget> list, Function(int index) clickItem,
{BaseIndicator baseIndicator}) {
TabBar(
{BaseIndicator baseIndicator, double fontSize, Color color, bool scroll}) {
return TabBar(
onTap: clickItem,
controller: controller,
indicatorSize: TabBarIndicatorSize.tab,
isScrollable: true,
isScrollable: scroll ?? true,
unselectedLabelColor: color ?? Color(0xffB5B5B5),
labelColor: color ?? Color(0xff282828),
labelStyle: TextStyle(fontSize: fontSize ?? 16),
unselectedLabelStyle: TextStyle(fontSize: fontSize ?? 16),
labelPadding: EdgeInsets.only(),
indicator: baseIndicator ?? BaseIndicator(),
tabs: list,
......@@ -416,15 +420,16 @@ Widget baseTabBarItem(
String text, {
double leftPadding,
double rightPadding,
double fontSize,
Color color,
}) {
double width = leftPadding??28 + text.length * 40.0 + rightPadding ??28;
print("WIDTH ${width}");
leftPadding = leftPadding ?? 28.0;
rightPadding = rightPadding ?? 28.0;
double width = leftPadding + text.length * 16.0 + rightPadding;
return Container(
height: 40,
width: width,
alignment: Alignment.center,
child: baseText(text, fontSize ?? 16, color ?? Color(0xffB5B5B5)),
child: Tab(
text: text,
),
);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment