Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
gm_flutter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林生雨
gm_flutter
Commits
d1df55f1
Commit
d1df55f1
authored
Jul 02, 2020
by
林生雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit :
parent
353d5b11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
340 additions
and
30 deletions
+340
-30
ClueRouter.dart
lib/ClueModel/ClueRouter.dart
+4
-1
ClueRouterImpl.dart
lib/ClueModel/ClueRouterImpl.dart
+6
-0
PlanCompareDetailModel.dart
...eModel/page/PlanCompareDetail/PlanCompareDetailModel.dart
+6
-0
PlanCompareDetailPage.dart
...ueModel/page/PlanCompareDetail/PlanCompareDetailPage.dart
+0
-0
PlanModel.dart
lib/ClueModel/page/plan/PlanModel.dart
+2
-0
PlanPage.dart
lib/ClueModel/page/plan/PlanPage.dart
+79
-27
TopModel.dart
lib/ClueModel/page/top/TopModel.dart
+25
-0
TopPage.dart
lib/ClueModel/page/top/TopPage.dart
+102
-0
FiveStarView.dart
lib/ClueModel/view/FiveStarView.dart
+3
-2
TestPage.dart
lib/MainRouter/page/test/TestPage.dart
+5
-0
BaseComponent.dart
lib/commonModel/base/BaseComponent.dart
+32
-0
WidgetUtil.dart
lib/commonModel/util/WidgetUtil.dart
+6
-0
baseTabIndicator.dart
lib/commonModel/view/baseTabIndicator.dart
+67
-0
main.dart
lib/main.dart
+3
-0
No files found.
lib/ClueModel/ClueRouter.dart
View file @
d1df55f1
...
...
@@ -18,6 +18,9 @@ abstract class ClueRouter implements RouterBaser {
Widget
getLevelTwoPage
();
Widget
getPlanPage
();
Widget
getPlanPage
();
Widget
getPlanCompareDetailPage
();
Widget
getTopPage
();
}
lib/ClueModel/ClueRouterImpl.dart
View file @
d1df55f1
...
...
@@ -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/plan/PlanPage.dart'
;
import
'package:gm_flutter/ClueModel/page/PlanCompareDetail/PlanCompareDetailPage.dart'
;
import
'package:gm_flutter/ClueModel/page/top/TopPage.dart'
;
class
ClueRouterImpl
implements
ClueRouter
{
@override
...
...
@@ -40,4 +41,9 @@ class ClueRouterImpl implements ClueRouter {
Widget
getPlanCompareDetailPage
()
{
return
PlanCompareDetailPage
();
}
@override
Widget
getTopPage
()
{
return
TopPage
();
}
}
lib/ClueModel/page/PlanCompareDetail/PlanCompareDetailModel.dart
View file @
d1df55f1
...
...
@@ -17,6 +17,7 @@ import 'package:gm_flutter/commonModel/bean/Pair.dart';
class
PlanCompareDetailModel
extends
BaseModel
{
LiveData
<
Pair
<
int
,
List
<
Groups
>>>
detailLive
=
LiveData
();
LiveData
<
Pair
<
int
,
List
<
PlansInfo
>>>
headerLive
=
LiveData
();
LiveData
<
int
>
stateLive
=
LiveData
();
RxDispose
rxDispose
=
RxDispose
();
...
...
@@ -25,13 +26,16 @@ class PlanCompareDetailModel extends BaseModel {
.
getPlanCompareDetail
(
DioUtil
.
getInstance
().
getDio
(),
planIds
)
.
listen
((
event
)
{
if
(
event
.
error
==
0
)
{
stateLive
.
notifyView
(
ENDLOADING
);
if
(
event
.
data
.
plansInfo
==
null
||
event
.
data
.
groups
.
isEmpty
)
{
headerLive
.
notifyView
(
Pair
(
ENDLOADING
,
[]));
detailLive
.
notifyView
(
Pair
(
ENDLOADING
,
[]));
}
else
{
detailLive
.
notifyView
(
Pair
(
ENDLOADING
,
event
.
data
.
groups
));
headerLive
.
notifyView
(
Pair
(
ENDLOADING
,
event
.
data
.
plansInfo
));
}
}
else
{
stateLive
.
notifyView
(
FAIL
);
NativeToast
.
showNativeToast
(
event
.
message
);
headerLive
.
notifyView
(
Pair
(
FAIL
,
null
));
detailLive
.
notifyView
(
Pair
(
FAIL
,
null
));
...
...
@@ -39,6 +43,7 @@ class PlanCompareDetailModel extends BaseModel {
})
.
addToDispose
(
rxDispose
)
.
onError
((
err
)
{
stateLive
.
notifyView
(
FAIL
);
headerLive
.
notifyView
(
Pair
(
FAIL
,
null
));
detailLive
.
notifyView
(
Pair
(
FAIL
,
null
));
NativeToast
.
showNativeToast
(
err
.
message
);
...
...
@@ -47,6 +52,7 @@ class PlanCompareDetailModel extends BaseModel {
@override
void
dispose
()
{
stateLive
.
dispost
();
detailLive
.
dispost
();
}
}
lib/ClueModel/page/PlanCompareDetail/PlanCompareDetailPage.dart
View file @
d1df55f1
This diff is collapsed.
Click to expand it.
lib/ClueModel/page/plan/PlanModel.dart
View file @
d1df55f1
...
...
@@ -20,6 +20,7 @@ class PlanModel extends BaseModel {
LiveData
<
List
<
double
>>
posLive
=
new
LiveData
();
LiveData
<
List
<
double
>>
backLive
=
new
LiveData
();
LiveData
<
List
<
Ranks
>>
picLive
=
LiveData
();
LiveData
<
bool
>
showTab
=
LiveData
();
LiveData
<
int
>
stateLive
=
LiveData
();
double
menuBottom
;
...
...
@@ -108,6 +109,7 @@ class PlanModel extends BaseModel {
posLive
.
dispost
();
backLive
.
dispost
();
feedsLive
.
dispost
();
showTab
.
dispost
();
}
void
backProgress
(
double
pro
,
int
index
)
{
...
...
lib/ClueModel/page/plan/PlanPage.dart
View file @
d1df55f1
...
...
@@ -9,6 +9,7 @@ import 'dart:ui';
import
'package:cached_network_image/cached_network_image.dart'
;
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/plan/FilterView.dart'
;
import
'package:gm_flutter/ClueModel/page/plan/PlanBar.dart'
;
import
'package:gm_flutter/ClueModel/page/plan/PlanItem.dart'
;
...
...
@@ -33,7 +34,7 @@ class PlanPage extends StatefulWidget {
State
<
StatefulWidget
>
createState
()
=>
PlanState
();
}
class
PlanState
extends
BaseState
<
PlanPage
>
{
class
PlanState
extends
BaseState
<
PlanPage
>
with
TickerProviderStateMixin
{
PlanModel
_model
=
PlanModel
();
TextEditingController
_editingController
=
TextEditingController
();
FocusNode
focusNode
=
FocusNode
();
...
...
@@ -53,8 +54,8 @@ class PlanState extends BaseState<PlanPage> {
_model
.
init
();
planBarView
=
PlanBarView
(
_model
.
managerLive
,
clickIndex
,
hideAllMenuListener
);
planList
.
add
(
towPic
());
planList
.
add
(
planBar
());
planList
.
add
(
towPic
()
.
toActive
()
);
planList
.
add
(
planBar
()
.
toActive
()
);
planList
.
add
(
pages
());
}
...
...
@@ -110,7 +111,9 @@ class PlanState extends BaseState<PlanPage> {
child:
Column
(
children:
<
Widget
>[
Container
(
height:
data
.
data
[
1
]
-
45
,
height:
data
.
data
[
1
]
-
45
<
0
?
0
:
data
.
data
[
1
]
-
45
,
color:
Colors
.
transparent
,
),
Container
(
...
...
@@ -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> {
focusNode:
focusNode
,
autocorrect:
false
,
autofocus:
false
,
textInputAction:
Platform
.
isAndroid
?
TextInputAction
.
newline
:
TextInputAction
.
send
,
textInputAction:
TextInputAction
.
search
,
controller:
_editingController
,
minLines:
null
,
onEditingComplete:
()
{},
...
...
@@ -316,27 +330,35 @@ class PlanState extends BaseState<PlanPage> {
}
Widget
child
()
{
return
baseRefreshView
(
refreshController
,
()
{
_model
.
refreshFeed
(
true
);
return
NotificationListener
(
onNotification:
(
scrollNotification
)
{
if
(
scrollNotification
is
ScrollUpdateNotification
&&
scrollNotification
.
metrics
.
axisDirection
.
index
==
2
)
{
_onScroll
(
scrollNotification
.
metrics
.
pixels
);
}
return
false
;
},
Container
(
width:
0
,
height:
0
,
),
SliverList
(
delegate:
SliverChildBuilderDelegate
(
(
BuildContext
context
,
int
index
)
{
return
planList
[
index
];
child:
baseRefreshView
(
refreshController
,
()
{
_model
.
refreshFeed
(
true
);
},
childCount:
planList
.
length
,
),
),
onLoading:
()
{
_model
.
loadMore
();
},
pullUp:
true
);
Container
(
width:
0
,
height:
0
,
),
SliverList
(
delegate:
SliverChildBuilderDelegate
(
(
BuildContext
context
,
int
index
)
{
return
planList
[
index
];
},
childCount:
planList
.
length
,
),
),
onLoading:
()
{
_model
.
loadMore
();
},
pullUp:
true
));
}
Widget
towPic
()
{
...
...
@@ -410,8 +432,14 @@ class PlanState extends BaseState<PlanPage> {
}
void
clickIndex
(
int
index
)
{
var
topPos
=
PosUtil
.
findPos
(
globalKey
);
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
;
if
(
_model
.
menuIndex
==
index
||
_model
.
menuIndex
==
-
1
)
{
_model
.
needChangBack
=
true
;
...
...
@@ -449,6 +477,7 @@ class PlanState extends BaseState<PlanPage> {
height
=
max
(
_model
.
feedDatas
.
length
*
100.0
,
height
);
}
return
Container
(
color:
Color
(
0xffF7F6FA
),
width:
double
.
maxFinite
,
height:
height
,
child:
ListView
.
builder
(
...
...
@@ -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);
}
}
lib/ClueModel/page/top/TopModel.dart
0 → 100644
View file @
d1df55f1
/*
* @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
);
}
}
lib/ClueModel/page/top/TopPage.dart
0 → 100644
View file @
d1df55f1
/*
* @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
;
}
}
lib/ClueModel/view/FiveStarView.dart
View file @
d1df55f1
...
...
@@ -7,8 +7,9 @@ import 'package:flutter/cupertino.dart';
class
FiveStarView
extends
StatelessWidget
{
final
int
allStarCount
;
final
int
lightStarCount
;
String
starAssets
;
FiveStarView
(
this
.
lightStarCount
,
this
.
allStarCount
);
FiveStarView
(
this
.
lightStarCount
,
this
.
allStarCount
,
{
this
.
starAssets
}
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -18,7 +19,7 @@ class FiveStarView extends StatelessWidget {
list
.
add
(
Container
(
height:
13
,
width:
13
,
child:
Image
.
asset
(
"assets/sel_star.png"
),
child:
Image
.
asset
(
starAssets
??
"assets/sel_star.png"
),
));
if
(
i
!=
0
&&
i
!=
allStarCount
-
1
)
{
list
.
add
(
Container
(
...
...
lib/MainRouter/page/test/TestPage.dart
View file @
d1df55f1
...
...
@@ -47,6 +47,11 @@ class TestState extends BaseState<TestPage> {
}));
list
.
add
(
listItem
(
"方案对比"
,
()
{
JumpUtil
.
jumpToPageRight
(
context
,
RouterCenterImpl
().
findClueRouter
().
getPlansCompareFeed
());
}));
list
.
add
(
listItem
(
"榜单"
,
()
{
JumpUtil
.
jumpToPageRight
(
context
,
RouterCenterImpl
().
findClueRouter
().
getTopPage
());
}));
return
list
;
}
...
...
lib/commonModel/base/BaseComponent.dart
View file @
d1df55f1
...
...
@@ -13,6 +13,7 @@ import 'package:flutter_svg/svg.dart';
import
'package:gm_flutter/commonModel/GMBase.dart'
;
import
'package:gm_flutter/commonModel/util/DartUtil.dart'
;
import
'package:gm_flutter/commonModel/view/ImagesAnimation.dart'
;
import
'package:gm_flutter/commonModel/view/baseTabIndicator.dart'
;
import
'package:lottie/lottie.dart'
;
import
'package:pull_to_refresh/pull_to_refresh.dart'
;
...
...
@@ -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
)),
);
}
lib/commonModel/util/WidgetUtil.dart
View file @
d1df55f1
...
...
@@ -19,7 +19,13 @@ class WidgetUtil {
}
static
RelativeRect
buttonLeftMenuPosition
(
BuildContext
c
)
{
if
(
c
==
null
)
{
return
null
;
}
final
RenderBox
bar
=
c
.
findRenderObject
();
if
(
Overlay
.
of
(
c
).
context
==
null
)
{
return
null
;
}
final
RenderBox
overlay
=
Overlay
.
of
(
c
).
context
.
findRenderObject
();
final
RelativeRect
position
=
RelativeRect
.
fromRect
(
Rect
.
fromPoints
(
...
...
lib/commonModel/view/baseTabIndicator.dart
0 → 100644
View file @
d1df55f1
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
);
}
}
lib/main.dart
View file @
d1df55f1
...
...
@@ -78,7 +78,10 @@ class MyApp extends State<MyAppWidget> {
theme:
ThemeData
(
primaryColor:
Colors
.
white
,
cursorColor:
Color
(
0xff20BDBB
),
highlightColor:
Colors
.
transparent
,
splashColor:
Colors
.
transparent
,
canvasColor:
Colors
.
white
),
builder:
FlutterBoost
.
init
(
postPush:
_onRoutePushed
),
home:
isDebug
?
RouterCenterImpl
().
findMainRouter
().
getTestPage
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment