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

commit :

parent 353d5b11
...@@ -18,6 +18,9 @@ abstract class ClueRouter implements RouterBaser { ...@@ -18,6 +18,9 @@ abstract class ClueRouter implements RouterBaser {
Widget getLevelTwoPage(); Widget getLevelTwoPage();
Widget getPlanPage(); Widget getPlanPage();
Widget getPlanCompareDetailPage(); Widget getPlanCompareDetailPage();
Widget getTopPage();
} }
...@@ -10,6 +10,7 @@ import 'package:gm_flutter/ClueModel/page/levelOne/LevelOnePage.dart'; ...@@ -10,6 +10,7 @@ import 'package:gm_flutter/ClueModel/page/levelOne/LevelOnePage.dart';
import 'package:gm_flutter/ClueModel/page/levelTwo/LevelTwoPage.dart'; import 'package:gm_flutter/ClueModel/page/levelTwo/LevelTwoPage.dart';
import 'package:gm_flutter/ClueModel/page/plan/PlanPage.dart'; import 'package:gm_flutter/ClueModel/page/plan/PlanPage.dart';
import 'package:gm_flutter/ClueModel/page/PlanCompareDetail/PlanCompareDetailPage.dart'; import 'package:gm_flutter/ClueModel/page/PlanCompareDetail/PlanCompareDetailPage.dart';
import 'package:gm_flutter/ClueModel/page/top/TopPage.dart';
class ClueRouterImpl implements ClueRouter { class ClueRouterImpl implements ClueRouter {
@override @override
...@@ -40,4 +41,9 @@ class ClueRouterImpl implements ClueRouter { ...@@ -40,4 +41,9 @@ class ClueRouterImpl implements ClueRouter {
Widget getPlanCompareDetailPage() { Widget getPlanCompareDetailPage() {
return PlanCompareDetailPage(); return PlanCompareDetailPage();
} }
@override
Widget getTopPage() {
return TopPage();
}
} }
...@@ -17,6 +17,7 @@ import 'package:gm_flutter/commonModel/bean/Pair.dart'; ...@@ -17,6 +17,7 @@ import 'package:gm_flutter/commonModel/bean/Pair.dart';
class PlanCompareDetailModel extends BaseModel { class PlanCompareDetailModel extends BaseModel {
LiveData<Pair<int, List<Groups>>> detailLive = LiveData(); LiveData<Pair<int, List<Groups>>> detailLive = LiveData();
LiveData<Pair<int, List<PlansInfo>>> headerLive = LiveData(); LiveData<Pair<int, List<PlansInfo>>> headerLive = LiveData();
LiveData<int> stateLive = LiveData();
RxDispose rxDispose = RxDispose(); RxDispose rxDispose = RxDispose();
...@@ -25,13 +26,16 @@ class PlanCompareDetailModel extends BaseModel { ...@@ -25,13 +26,16 @@ class PlanCompareDetailModel extends BaseModel {
.getPlanCompareDetail(DioUtil.getInstance().getDio(), planIds) .getPlanCompareDetail(DioUtil.getInstance().getDio(), planIds)
.listen((event) { .listen((event) {
if (event.error == 0) { if (event.error == 0) {
stateLive.notifyView(ENDLOADING);
if (event.data.plansInfo == null || event.data.groups.isEmpty) { if (event.data.plansInfo == null || event.data.groups.isEmpty) {
headerLive.notifyView(Pair(ENDLOADING, [])); headerLive.notifyView(Pair(ENDLOADING, []));
detailLive.notifyView(Pair(ENDLOADING, [])); detailLive.notifyView(Pair(ENDLOADING, []));
} else { } else {
detailLive.notifyView(Pair(ENDLOADING, event.data.groups)); detailLive.notifyView(Pair(ENDLOADING, event.data.groups));
headerLive.notifyView(Pair(ENDLOADING, event.data.plansInfo));
} }
} else { } else {
stateLive.notifyView(FAIL);
NativeToast.showNativeToast(event.message); NativeToast.showNativeToast(event.message);
headerLive.notifyView(Pair(FAIL, null)); headerLive.notifyView(Pair(FAIL, null));
detailLive.notifyView(Pair(FAIL, null)); detailLive.notifyView(Pair(FAIL, null));
...@@ -39,6 +43,7 @@ class PlanCompareDetailModel extends BaseModel { ...@@ -39,6 +43,7 @@ class PlanCompareDetailModel extends BaseModel {
}) })
.addToDispose(rxDispose) .addToDispose(rxDispose)
.onError((err) { .onError((err) {
stateLive.notifyView(FAIL);
headerLive.notifyView(Pair(FAIL, null)); headerLive.notifyView(Pair(FAIL, null));
detailLive.notifyView(Pair(FAIL, null)); detailLive.notifyView(Pair(FAIL, null));
NativeToast.showNativeToast(err.message); NativeToast.showNativeToast(err.message);
...@@ -47,6 +52,7 @@ class PlanCompareDetailModel extends BaseModel { ...@@ -47,6 +52,7 @@ class PlanCompareDetailModel extends BaseModel {
@override @override
void dispose() { void dispose() {
stateLive.dispost();
detailLive.dispost(); detailLive.dispost();
} }
} }
...@@ -20,6 +20,7 @@ class PlanModel extends BaseModel { ...@@ -20,6 +20,7 @@ class PlanModel extends BaseModel {
LiveData<List<double>> posLive = new LiveData(); LiveData<List<double>> posLive = new LiveData();
LiveData<List<double>> backLive = new LiveData(); LiveData<List<double>> backLive = new LiveData();
LiveData<List<Ranks>> picLive = LiveData(); LiveData<List<Ranks>> picLive = LiveData();
LiveData<bool> showTab = LiveData();
LiveData<int> stateLive = LiveData(); LiveData<int> stateLive = LiveData();
double menuBottom; double menuBottom;
...@@ -108,6 +109,7 @@ class PlanModel extends BaseModel { ...@@ -108,6 +109,7 @@ class PlanModel extends BaseModel {
posLive.dispost(); posLive.dispost();
backLive.dispost(); backLive.dispost();
feedsLive.dispost(); feedsLive.dispost();
showTab.dispost();
} }
void backProgress(double pro, int index) { void backProgress(double pro, int index) {
......
...@@ -9,6 +9,7 @@ import 'dart:ui'; ...@@ -9,6 +9,7 @@ import 'dart:ui';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gm_flutter/ClueModel/page/levelTwo/LevelTwoPage.dart';
import 'package:gm_flutter/ClueModel/page/plan/FilterView.dart'; import 'package:gm_flutter/ClueModel/page/plan/FilterView.dart';
import 'package:gm_flutter/ClueModel/page/plan/PlanBar.dart'; import 'package:gm_flutter/ClueModel/page/plan/PlanBar.dart';
import 'package:gm_flutter/ClueModel/page/plan/PlanItem.dart'; import 'package:gm_flutter/ClueModel/page/plan/PlanItem.dart';
...@@ -33,7 +34,7 @@ class PlanPage extends StatefulWidget { ...@@ -33,7 +34,7 @@ class PlanPage extends StatefulWidget {
State<StatefulWidget> createState() => PlanState(); State<StatefulWidget> createState() => PlanState();
} }
class PlanState extends BaseState<PlanPage> { class PlanState extends BaseState<PlanPage> with TickerProviderStateMixin {
PlanModel _model = PlanModel(); PlanModel _model = PlanModel();
TextEditingController _editingController = TextEditingController(); TextEditingController _editingController = TextEditingController();
FocusNode focusNode = FocusNode(); FocusNode focusNode = FocusNode();
...@@ -53,8 +54,8 @@ class PlanState extends BaseState<PlanPage> { ...@@ -53,8 +54,8 @@ class PlanState extends BaseState<PlanPage> {
_model.init(); _model.init();
planBarView = planBarView =
PlanBarView(_model.managerLive, clickIndex, hideAllMenuListener); PlanBarView(_model.managerLive, clickIndex, hideAllMenuListener);
planList.add(towPic()); planList.add(towPic().toActive());
planList.add(planBar()); planList.add(planBar().toActive());
planList.add(pages()); planList.add(pages());
} }
...@@ -110,7 +111,9 @@ class PlanState extends BaseState<PlanPage> { ...@@ -110,7 +111,9 @@ class PlanState extends BaseState<PlanPage> {
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
Container( Container(
height: data.data[1] - 45, height: data.data[1] - 45 < 0
? 0
: data.data[1] - 45,
color: Colors.transparent, color: Colors.transparent,
), ),
Container( Container(
...@@ -215,6 +218,19 @@ class PlanState extends BaseState<PlanPage> { ...@@ -215,6 +218,19 @@ class PlanState extends BaseState<PlanPage> {
}, },
); );
}), }),
StreamBuilder<bool>(
stream: _model.showTab.stream,
initialData: _model.showTab.data ?? false,
builder: (c, data) {
return Visibility(
visible: data.data,
child: Container(
color: Colors.white,
child: planBarView,
),
);
},
)
], ],
), ),
) )
...@@ -303,9 +319,7 @@ class PlanState extends BaseState<PlanPage> { ...@@ -303,9 +319,7 @@ class PlanState extends BaseState<PlanPage> {
focusNode: focusNode, focusNode: focusNode,
autocorrect: false, autocorrect: false,
autofocus: false, autofocus: false,
textInputAction: Platform.isAndroid textInputAction: TextInputAction.search,
? TextInputAction.newline
: TextInputAction.send,
controller: _editingController, controller: _editingController,
minLines: null, minLines: null,
onEditingComplete: () {}, onEditingComplete: () {},
...@@ -316,27 +330,35 @@ class PlanState extends BaseState<PlanPage> { ...@@ -316,27 +330,35 @@ class PlanState extends BaseState<PlanPage> {
} }
Widget child() { Widget child() {
return baseRefreshView( return NotificationListener(
refreshController, onNotification: (scrollNotification) {
() { if (scrollNotification is ScrollUpdateNotification &&
_model.refreshFeed(true); scrollNotification.metrics.axisDirection.index == 2) {
_onScroll(scrollNotification.metrics.pixels);
}
return false;
}, },
Container( child: baseRefreshView(
width: 0, refreshController,
height: 0, () {
), _model.refreshFeed(true);
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return planList[index];
}, },
childCount: planList.length, Container(
), width: 0,
), height: 0,
onLoading: () { ),
_model.loadMore(); SliverList(
}, delegate: SliverChildBuilderDelegate(
pullUp: true); (BuildContext context, int index) {
return planList[index];
},
childCount: planList.length,
),
),
onLoading: () {
_model.loadMore();
},
pullUp: true));
} }
Widget towPic() { Widget towPic() {
...@@ -410,8 +432,14 @@ class PlanState extends BaseState<PlanPage> { ...@@ -410,8 +432,14 @@ class PlanState extends BaseState<PlanPage> {
} }
void clickIndex(int index) { void clickIndex(int index) {
var topPos = PosUtil.findPos(globalKey);
double bottom = double bottom =
WidgetUtil.buttonLeftMenuPosition(globalKey.currentContext).top - 86; // WidgetUtil.buttonLeftMenuPosition(globalKey.currentContext)?.top ??
topPos == null ? 0.0 : topPos.dy + 45 - 86;
if (bottom < 45) {
bottom = 45;
}
_model.menuBottom = bottom; _model.menuBottom = bottom;
if (_model.menuIndex == index || _model.menuIndex == -1) { if (_model.menuIndex == index || _model.menuIndex == -1) {
_model.needChangBack = true; _model.needChangBack = true;
...@@ -449,6 +477,7 @@ class PlanState extends BaseState<PlanPage> { ...@@ -449,6 +477,7 @@ class PlanState extends BaseState<PlanPage> {
height = max(_model.feedDatas.length * 100.0, height); height = max(_model.feedDatas.length * 100.0, height);
} }
return Container( return Container(
color: Color(0xffF7F6FA),
width: double.maxFinite, width: double.maxFinite,
height: height, height: height,
child: ListView.builder( child: ListView.builder(
...@@ -479,4 +508,27 @@ class PlanState extends BaseState<PlanPage> { ...@@ -479,4 +508,27 @@ class PlanState extends BaseState<PlanPage> {
}, },
); );
} }
void _onScroll(double offset) {
var topPos = PosUtil.findPos(globalKey);
if (topPos != null) {
if (topPos.dy > 86) {
_model.showTab.notifyView(false);
} else {
_model.showTab.notifyView(true);
}
}
// if (topPos != null && topPos.dy < 0) {
// double dy = -topPos.dy;
// if (dy < 20) {
// dy = 0;
// }
// double alpha = dy / 112;
// if (alpha < 0) {
// alpha = 0;
// } else if (alpha > 1) {
// alpha = 1;
// }
// _model.showTab.notifyView(alpha);
}
} }
/*
* @author lsy
* @date 2020/7/2
**/
import 'package:flutter_common/commonModel/live/BaseModel.dart';
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 selectTab(int index) {
if (tabIndex == index) {
return;
}
tabIndex = index;
tabIndexLive.notifyView(index);
}
}
/*
* @author lsy
* @date 2020/7/2
**/
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:gm_flutter/ClueModel/page/levelTwo/LevelTwoPage.dart';
import 'package:gm_flutter/ClueModel/page/top/TopModel.dart';
import 'package:gm_flutter/commonModel/base/BaseComponent.dart';
import 'package:gm_flutter/commonModel/base/BaseState.dart';
import 'package:gm_flutter/commonModel/view/baseTabIndicator.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
class TopPage extends StatefulWidget {
@override
State<StatefulWidget> createState() => TopPageState();
}
class TopPageState extends BaseState<TopPage> with TickerProviderStateMixin {
RefreshController refreshController = RefreshController();
TabController tabController;
TopModel _model = TopModel();
@override
void initState() {
tabController = TabController(length: 4, vsync: this);
super.initState();
}
@override
void dispose() {
refreshController.dispose();
super.dispose();
}
@override
Widget buildItem(BuildContext context) {
return Scaffold(
body: home(),
);
}
Widget home() {
return baseRefreshView(refreshController, () {}, null, null,
customScrollView: CustomScrollView(slivers: <Widget>[
SliverAppBar(
pinned: true,
elevation: 0,
expandedHeight: 0,
flexibleSpace: FlexibleSpaceBar(title: Text('二级方案')),
),
SliverToBoxAdapter(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Container(
height: 50,
)
],
)),
SliverPersistentHeader(
pinned: true,
delegate: StickyTabBarDelegate(
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,
)
]))
]));
}
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)));
}
return list;
}
}
...@@ -7,8 +7,9 @@ import 'package:flutter/cupertino.dart'; ...@@ -7,8 +7,9 @@ import 'package:flutter/cupertino.dart';
class FiveStarView extends StatelessWidget { class FiveStarView extends StatelessWidget {
final int allStarCount; final int allStarCount;
final int lightStarCount; final int lightStarCount;
String starAssets;
FiveStarView(this.lightStarCount, this.allStarCount); FiveStarView(this.lightStarCount, this.allStarCount, {this.starAssets});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -18,7 +19,7 @@ class FiveStarView extends StatelessWidget { ...@@ -18,7 +19,7 @@ class FiveStarView extends StatelessWidget {
list.add(Container( list.add(Container(
height: 13, height: 13,
width: 13, width: 13,
child: Image.asset("assets/sel_star.png"), child: Image.asset(starAssets ?? "assets/sel_star.png"),
)); ));
if (i != 0 && i != allStarCount - 1) { if (i != 0 && i != allStarCount - 1) {
list.add(Container( list.add(Container(
......
...@@ -47,6 +47,11 @@ class TestState extends BaseState<TestPage> { ...@@ -47,6 +47,11 @@ class TestState extends BaseState<TestPage> {
})); }));
list.add(listItem("方案对比", () { list.add(listItem("方案对比", () {
JumpUtil.jumpToPageRight(context, RouterCenterImpl().findClueRouter().getPlansCompareFeed()); JumpUtil.jumpToPageRight(context, RouterCenterImpl().findClueRouter().getPlansCompareFeed());
}));
list.add(listItem("榜单", () {
JumpUtil.jumpToPageRight(context, RouterCenterImpl().findClueRouter().getTopPage());
})); }));
return list; return list;
} }
......
...@@ -13,6 +13,7 @@ import 'package:flutter_svg/svg.dart'; ...@@ -13,6 +13,7 @@ import 'package:flutter_svg/svg.dart';
import 'package:gm_flutter/commonModel/GMBase.dart'; import 'package:gm_flutter/commonModel/GMBase.dart';
import 'package:gm_flutter/commonModel/util/DartUtil.dart'; import 'package:gm_flutter/commonModel/util/DartUtil.dart';
import 'package:gm_flutter/commonModel/view/ImagesAnimation.dart'; import 'package:gm_flutter/commonModel/view/ImagesAnimation.dart';
import 'package:gm_flutter/commonModel/view/baseTabIndicator.dart';
import 'package:lottie/lottie.dart'; import 'package:lottie/lottie.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
...@@ -396,3 +397,34 @@ Widget emptyItem(double width, double height, {String detail}) { ...@@ -396,3 +397,34 @@ Widget emptyItem(double width, double height, {String detail}) {
), ),
); );
} }
Widget baseTabBar(
TabController controller, List<Widget> list, Function(int index) clickItem,
{BaseIndicator baseIndicator}) {
TabBar(
onTap: clickItem,
controller: controller,
indicatorSize: TabBarIndicatorSize.tab,
isScrollable: true,
labelPadding: EdgeInsets.only(),
indicator: baseIndicator ?? BaseIndicator(),
tabs: list,
);
}
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}");
return Container(
height: 40,
width: width,
alignment: Alignment.center,
child: baseText(text, fontSize ?? 16, color ?? Color(0xffB5B5B5)),
);
}
...@@ -19,7 +19,13 @@ class WidgetUtil { ...@@ -19,7 +19,13 @@ class WidgetUtil {
} }
static RelativeRect buttonLeftMenuPosition(BuildContext c) { static RelativeRect buttonLeftMenuPosition(BuildContext c) {
if (c == null) {
return null;
}
final RenderBox bar = c.findRenderObject(); final RenderBox bar = c.findRenderObject();
if (Overlay.of(c).context == null) {
return null;
}
final RenderBox overlay = Overlay.of(c).context.findRenderObject(); final RenderBox overlay = Overlay.of(c).context.findRenderObject();
final RelativeRect position = RelativeRect.fromRect( final RelativeRect position = RelativeRect.fromRect(
Rect.fromPoints( Rect.fromPoints(
......
library md2_tab_indicator;
import 'package:flutter/widgets.dart';
class BaseIndicator extends Decoration {
double indicatorHeight;
Color indicatorColor;
double indicatorRadius;
double indicatorWidth;
double indicatorPaddingBottom;
BaseIndicator(
{this.indicatorHeight,
this.indicatorColor,
this.indicatorRadius,
this.indicatorWidth,
this.indicatorPaddingBottom}) {
indicatorHeight = indicatorHeight ?? 3.0;
indicatorColor = indicatorColor ?? Color(0xff3FB5AF);
indicatorRadius = indicatorRadius ?? 1.5;
indicatorWidth = indicatorWidth ?? 22.0;
indicatorPaddingBottom = indicatorPaddingBottom ?? 6.0;
}
@override
_MD2Painter createBoxPainter([VoidCallback onChanged]) {
return new _MD2Painter(this, onChanged);
}
}
class _MD2Painter extends BoxPainter {
final BaseIndicator decoration;
_MD2Painter(this.decoration, VoidCallback onChanged)
: assert(decoration != null),
super(onChanged);
@override
void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
assert(configuration != null);
assert(configuration.size != null);
Rect rect = Offset(
offset.dx +
configuration.size.width / 2 -
decoration.indicatorWidth / 2,
(configuration.size.height -
decoration.indicatorHeight -
decoration.indicatorPaddingBottom)) &
Size(decoration.indicatorWidth, decoration.indicatorHeight);
final Paint paint = Paint();
paint.color = decoration.indicatorColor;
paint.style = PaintingStyle.fill;
double radius = decoration.indicatorRadius;
canvas.drawRRect(
RRect.fromRectAndCorners(rect,
topRight: Radius.circular(radius),
topLeft: Radius.circular(radius),
bottomLeft: Radius.circular(radius),
bottomRight: Radius.circular(radius)),
paint);
}
}
...@@ -78,7 +78,10 @@ class MyApp extends State<MyAppWidget> { ...@@ -78,7 +78,10 @@ class MyApp extends State<MyAppWidget> {
theme: ThemeData( theme: ThemeData(
primaryColor: Colors.white, primaryColor: Colors.white,
cursorColor: Color(0xff20BDBB), cursorColor: Color(0xff20BDBB),
highlightColor:Colors.transparent,
splashColor:Colors.transparent,
canvasColor: Colors.white), canvasColor: Colors.white),
builder: FlutterBoost.init(postPush: _onRoutePushed), builder: FlutterBoost.init(postPush: _onRoutePushed),
home: isDebug home: isDebug
? RouterCenterImpl().findMainRouter().getTestPage() ? RouterCenterImpl().findMainRouter().getTestPage()
......
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