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
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
483 additions
and
139 deletions
+483
-139
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
+143
-109
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
...
...
@@ -25,6 +25,7 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
PlanCompareDetailModel
_model
=
new
PlanCompareDetailModel
();
double
screenWidth
;
List
<
Widget
>
viewList
=
new
List
();
@override
void
initState
()
{
super
.
initState
();
...
...
@@ -60,133 +61,170 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
Widget
reloadPage
()
{
return
StreamBuilder
(
stream:
_model
.
detail
Live
.
stream
,
initialData:
_model
.
detailLive
.
data
??
Pair
(
LOADING
,
null
)
,
stream:
_model
.
state
Live
.
stream
,
initialData:
_model
.
stateLive
.
data
??
LOADING
,
builder:
(
c
,
data
)
{
if
(
data
.
data
.
first
==
FAIL
)
{
if
(
data
.
data
==
FAIL
)
{
return
errorItem
(
MediaQuery
.
of
(
context
).
size
.
width
,
MediaQuery
.
of
(
context
).
size
.
height
,
()
{
_model
.
init
([
1
,
2
]);
});
}
if
(
data
.
data
.
first
==
LOADING
||
_model
.
detailLive
==
null
)
{
if
(
data
.
data
==
LOADING
)
{
return
loadingItem
();
}
if
(
data
.
data
.
second
.
length
==
0
)
{
return
emptyItem
(
MediaQuery
.
of
(
context
).
size
.
width
,
MediaQuery
.
of
(
context
).
size
.
height
);
}
return
setupHome
([],
data
.
data
.
second
);
return
setupHome
();
},
);
}
Widget
setupHome
(
List
<
PlansInfo
>
plansInfo
,
List
<
Groups
>
groups
)
{
Widget
setupHome
()
{
return
Column
(
children:
<
Widget
>[
head
(),
Expanded
(
child:
Container
(
margin:
EdgeInsets
.
fromLTRB
(
15
,
0
,
15
,
0
),
color:
Colors
.
green
,
child:
ListView
.
builder
(
itemBuilder:
(
BuildContext
context
,
int
index
)
{
Groups
group
=
groups
[
index
];
switch
(
group
.
groupType
)
{
case
'hot'
:
// return planPopularityView(plansInfo);
// return planNormalEffectiveAttrsView(group);
child:
Container
(
child:
StreamBuilder
<
Pair
<
int
,
List
<
Groups
>>>(
stream:
_model
.
detailLive
.
stream
,
initialData:
_model
.
detailLive
.
data
??
Pair
(
LOADING
,
null
),
builder:
(
c
,
data
)
{
if
(
data
.
data
.
first
==
FAIL
)
{
return
errorItem
(
MediaQuery
.
of
(
context
).
size
.
width
,
MediaQuery
.
of
(
context
).
size
.
height
,
()
{
//TODO
});
}
return
ListView
.
builder
(
itemBuilder:
(
BuildContext
context
,
int
index
)
{
if
(
index
==
data
.
data
.
second
.
length
*
2
-
1
)
{
return
Container
(
height:
10
0
,
color:
Color
s
.
red
,
height:
4
0
,
color:
Color
(
0xffF7F6FA
)
,
);
break
;
case
'normal_attrs'
:
}
if
(
index
%
2
!=
0
)
{
return
Container
(
// height: double.maxFinite,
color:
Colors
.
yellow
,
height:
5
,
color:
Color
(
0xffF7F6FA
),
);
}
int
newIndex
=
(
index
/
2
).
floor
();
Groups
group
=
data
.
data
.
second
[
newIndex
];
Widget
widget
;
if
(
group
.
groupType
==
'hot'
)
{
widget
=
Container
(
height:
100
,
alignment:
Alignment
.
center
,
child:
baseText
(
"第一个"
,
15
,
Colors
.
black
),
);
}
else
if
(
group
.
groupType
==
'normal_attrs'
)
{
widget
=
Container
(
child:
planNormalEffectiveAttrsView
(
group
),
);
// return planNormalEffectiveAttrsView(group);
break
;
case
'effective_attrs'
:
return
Container
(
// height: double.maxFinite,
color:
Colors
.
blue
,
}
else
if
(
group
.
groupType
==
'effective_attrs'
)
{
widget
=
Container
(
child:
planNormalEffectiveAttrsView
(
group
),
);
// return planNormalEffectiveAttrsView(group);
break
;
default
:
return
planNormalEffectiveAttrsView
(
group
);
}
},
itemCount:
groups
.
length
,
)),
)
}
else
{
widget
=
planNormalEffectiveAttrsView
(
group
);
}
return
Container
(
margin:
EdgeInsets
.
only
(
left:
15
,
right:
15
),
child:
widget
,
);
},
itemCount:
data
.
data
.
second
.
length
*
2
,
);
}),
))
],
);
}
Widget
head
()
{
PlansInfo
plan
;
return
Container
(
// key: keyTop,
color:
Colors
.
yellow
,
width:
screenWidth
,
height:
105
,
alignment:
Alignment
.
topLeft
,
margin:
EdgeInsets
.
fromLTRB
(
9.5
,
0
,
9.5
,
0
),
margin:
EdgeInsets
.
only
(
left:
15
,
right:
15
),
child:
Row
(
children:
<
Widget
>[
// 根据 flex系数,分配剩余空间
Expanded
(
flex:
1
,
child:
headItem
(
plan
)),
Expanded
(
flex:
1
,
child:
headItem
(
plan
))
Expanded
(
flex:
1
,
child:
headItem
(
0
)),
Expanded
(
flex:
1
,
child:
headItem
(
1
))
]),
);
}
Widget
headItem
(
PlansInfo
plan
)
{
return
Container
(
child:
Stack
(
children:
<
Widget
>[
Positioned
(
child:
Container
(
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
15
),
),
alignment:
Alignment
.
center
,
margin:
EdgeInsets
.
fromLTRB
(
5.5
,
15
,
5.5
,
15
),
child:
Image
.
asset
(
'assets/plan_compare_detail_info_bg.png'
,
fit:
BoxFit
.
cover
),
)),
Positioned
(
left:
17.5
,
top:
31
,
child:
baseText
(
'11111'
,
15
,
Color
(
0xff333333
),
bold:
true
),
),
Positioned
(
left:
17.5
,
bottom:
31
,
child:
baseText
(
'¥¥¥¥¥¥¥¥¥¥'
,
14
,
Colors
.
red
,
bold:
true
),
),
]));
Widget
headItem
(
int
index
)
{
return
StreamBuilder
(
stream:
_model
.
headerLive
.
stream
,
initialData:
_model
.
headerLive
.
data
??
null
,
builder:
(
c
,
data
)
{
if
(
data
.
data
==
null
)
{
return
Container
();
}
return
Container
(
child:
Stack
(
children:
<
Widget
>[
Positioned
(
top:
8
,
left:
index
==
0
?
0
:
5.5
,
child:
Container
(
height:
75
,
width:
(
screenWidth
-
30
-
11
)
/
2
,
child:
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
15
),
child:
Image
.
asset
(
'assets/plan_compare_detail_info_bg.png'
,
fit:
BoxFit
.
cover
),
),
)),
Positioned
(
left:
12
,
top:
24
,
child:
baseText
(
'11111'
,
15
,
Color
(
0xff333333
),
bold:
true
),
),
Positioned
(
left:
12
,
top:
48
,
child:
baseText
(
'¥¥¥¥¥¥¥¥¥¥'
,
14
,
Colors
.
red
,
bold:
true
),
),
]));
},
);
}
Widget
titleView
(
String
title
)
{
return
Container
(
height:
81
,
height:
75
,
width:
screenWidth
,
color:
Colors
.
cyan
,
margin:
EdgeInsets
.
fromLTRB
(
0
,
30
,
0
,
13
),
alignment:
Alignment
.
topCenter
,
margin:
EdgeInsets
.
fromLTRB
(
0
,
30
,
0
,
20
),
alignment:
Alignment
.
center
,
child:
Container
(
child:
baseText
(
title
,
21
,
Colors
.
black
,
bold:
true
),
width:
90
,
height:
25
,
child:
Stack
(
alignment:
AlignmentDirectional
.
center
,
children:
<
Widget
>[
Positioned
(
bottom:
0
,
child:
Container
(
width:
90
,
height:
10
,
child:
Image
.
asset
(
"assets/plan_compare_detail_title_bg.png"
),
),
),
Positioned
(
top:
0
,
child:
baseText
(
title
,
21
,
Color
(
0xff282828
),
bold:
true
),
)
],
),
),
);
}
Widget
planPopularityView
(
List
<
PlansInfo
>
planInfo
)
{
return
Container
(
color:
Colors
.
green
,
height:
265
,
child:
Container
(
child:
Column
(
children:
<
Widget
>[
...
...
@@ -292,34 +330,34 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
list
.
add
(
planBaseAttrsView
(
element
));
});
return
Container
(
color:
Colors
.
green
,
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
list
child:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
list
// <Widget>[
// Expanded(
// child: Stack(children: <Widget>[
// ,
// Expanded(
// child: Container(
// margin: EdgeInsets.fromLTRB(0, 68, 0, 0),
// child:
// ListView.builder(
// shrinkWrap: true,
// physics: NeverScrollableScrollPhysics(),
// itemBuilder: (c, index) {
// return planBaseAttrsView(groups.plans);
// },
// itemCount: 5,
// )))
// ]))
));
// <Widget>[
// Expanded(
// child: Stack(children: <Widget>[
// ,
// Expanded(
// child: Container(
// margin: EdgeInsets.fromLTRB(0, 68, 0, 0),
// child:
// ListView.builder(
// shrinkWrap: true,
// physics: NeverScrollableScrollPhysics(),
// itemBuilder: (c, index) {
// return planBaseAttrsView(groups.plans);
// },
// itemCount: 5,
// )))
// ]))
));
}
Widget
planBaseAttrsView
(
Plans
plans
)
{
return
Container
(
color:
Colors
.
red
,
height:
80
,
height:
56
,
child:
Row
(
children:
<
Widget
>[
Expanded
(
flex:
1
,
child:
planBaseAttrsLeftView
(
plans
)),
Expanded
(
flex:
1
,
child:
planBaseAttrsRightView
(
plans
))
...
...
@@ -328,18 +366,16 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
Widget
planBaseAttrsLeftView
(
Plans
plan
)
{
return
Container
(
color:
Colors
.
red
,
height:
80
,
height:
56
,
child:
Stack
(
children:
<
Widget
>[
Positioned
(
right:
20
,
top:
12
,
top:
0
,
child:
baseText
(
plan
.
attrs
[
0
].
attrValue
,
14
,
Color
(
0xff3FB5AF
),
bold:
true
)),
Positioned
(
top:
20
,
right:
20
,
// top: 12,
bottom:
12
,
child:
baseText
(
plan
.
attrs
[
0
].
attrName
,
12
,
Color
(
0xff666666
),
bold:
false
),
),
...
...
@@ -348,18 +384,16 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
Widget
planBaseAttrsRightView
(
Plans
plan
)
{
return
Container
(
color:
Colors
.
red
,
height:
80
,
height:
56
,
child:
Stack
(
children:
<
Widget
>[
Positioned
(
left:
20
,
top:
12
,
top:
0
,
child:
baseText
(
plan
.
attrs
[
0
].
attrValue
,
14
,
Color
(
0xffF25874
),
bold:
true
)),
Positioned
(
left:
20
,
// top: 12,
bottom:
12
,
top:
20
,
child:
baseText
(
plan
.
attrs
[
0
].
attrName
,
12
,
Color
(
0xff666666
),
bold:
false
),
),
...
...
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