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
44fc10b9
Commit
44fc10b9
authored
Jul 08, 2020
by
林生雨
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'zx/gmFlutter' into 'test'
Zx/gm flutter See merge request
!22
parents
553ec9d8
2bb4c8a5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
106 deletions
+105
-106
PlanCompareDetailPage.dart
...ueModel/page/PlanCompareDetail/PlanCompareDetailPage.dart
+105
-106
No files found.
lib/ClueModel/page/PlanCompareDetail/PlanCompareDetailPage.dart
View file @
44fc10b9
...
...
@@ -4,6 +4,9 @@
* @Last Modified by: zx
* @Last Modified time: 2020-07-03 13:47:57
*/
import
'dart:ffi'
;
import
'dart:math'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'package:gm_flutter/ClueModel/page/PlanCompareDetail/PlanCompareDetailModel.dart'
;
...
...
@@ -29,7 +32,6 @@ class PlanCompareDetailPage extends StatefulWidget {
class
PlanCompareDetailPageState
extends
BaseState
<
PlanCompareDetailPage
>
{
PlanCompareDetailModel
_model
=
new
PlanCompareDetailModel
();
double
screenWidth
;
@override
void
initState
()
{
super
.
initState
();
...
...
@@ -44,10 +46,7 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
@override
Widget
buildItem
(
BuildContext
context
)
{
screenWidth
=
MediaQuery
.
of
(
context
)
.
size
.
width
;
screenWidth
=
MediaQuery
.
of
(
context
).
size
.
width
;
return
Scaffold
(
appBar:
baseAppBar
(
title:
"对比详情"
,
...
...
@@ -66,16 +65,10 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
initialData:
_model
.
stateLive
.
data
??
LOADING
,
builder:
(
c
,
data
)
{
if
(
data
.
data
==
FAIL
)
{
return
errorItem
(
MediaQuery
.
of
(
context
)
.
size
.
width
,
MediaQuery
.
of
(
context
)
.
size
.
height
,
()
{
_model
.
init
(
widget
.
_planIds
);
});
return
errorItem
(
MediaQuery
.
of
(
context
).
size
.
width
,
MediaQuery
.
of
(
context
).
size
.
height
,
()
{
_model
.
init
(
widget
.
_planIds
);
});
}
if
(
data
.
data
==
LOADING
)
{
return
loadingItem
();
...
...
@@ -91,66 +84,60 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
head
(),
Expanded
(
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
,
()
{
_model
.
init
(
widget
.
_planIds
);
});
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
,
()
{
_model
.
init
(
widget
.
_planIds
);
});
}
return
ListView
.
builder
(
itemBuilder:
(
BuildContext
context
,
int
index
)
{
if
(
index
==
data
.
data
.
second
.
length
*
2
-
1
)
{
return
Container
(
height:
40
,
color:
Color
(
0xffF7F6FA
),
);
}
if
(
index
%
2
!=
0
)
{
return
Container
(
height:
5
,
color:
Color
(
0xffF7F6FA
),
);
}
int
newIndex
=
(
index
/
2
).
floor
();
Groups
group
=
data
.
data
.
second
[
newIndex
];
Widget
widget
;
if
(
group
.
groupType
==
'hot'
)
{
widget
=
Container
(
child:
planPopularityView
(
group
),
// height: 100,
// alignment: Alignment.center,
// child: baseText("第一个", 15, Colors.black),
);
}
else
if
(
group
.
groupType
==
'normal_attrs'
)
{
widget
=
Container
(
child:
planNormalEffectiveAttrsView
(
group
),
);
}
else
if
(
group
.
groupType
==
'effective_attrs'
)
{
widget
=
Container
(
child:
planNormalEffectiveAttrsView
(
group
),
);
}
else
{
widget
=
planNormalEffectiveAttrsView
(
group
);
}
return
ListView
.
builder
(
itemBuilder:
(
BuildContext
context
,
int
index
)
{
if
(
index
==
data
.
data
.
second
.
length
*
2
-
1
)
{
return
Container
(
height:
40
,
color:
Color
(
0xffF7F6FA
),
);
}
if
(
index
%
2
!=
0
)
{
return
Container
(
height:
5
,
color:
Color
(
0xffF7F6FA
),
);
}
int
newIndex
=
(
index
/
2
).
floor
();
Groups
group
=
data
.
data
.
second
[
newIndex
];
Widget
widget
;
if
(
group
.
groupType
==
'hot'
)
{
widget
=
Container
(
child:
planPopularityView
(
group
),
// height: 100,
// alignment: Alignment.center,
// child: baseText("第一个", 15, Colors.black),
);
}
else
if
(
group
.
groupType
==
'normal_attrs'
)
{
widget
=
Container
(
child:
planNormalEffectiveAttrsView
(
group
),
);
}
else
if
(
group
.
groupType
==
'effective_attrs'
)
{
widget
=
Container
(
child:
planNormalEffectiveAttrsView
(
group
),
);
}
else
{
widget
=
planNormalEffectiveAttrsView
(
group
);
}
return
Container
(
margin:
EdgeInsets
.
only
(
left:
15
,
right:
15
),
child:
widget
,
);
},
itemCount:
data
.
data
.
second
.
length
*
2
,
return
Container
(
margin:
EdgeInsets
.
only
(
left:
15
,
right:
15
),
child:
widget
,
);
}),
))
},
itemCount:
data
.
data
.
second
.
length
*
2
,
);
}),
))
],
);
}
...
...
@@ -181,34 +168,32 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
PlansInfo
planinfo
=
data
.
data
.
second
[
index
];
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
(
7
),
child:
Image
.
asset
(
'assets/plan_compare_detail_info_bg.png'
,
fit:
BoxFit
.
cover
),
),
)),
Positioned
(
left:
12
,
top:
24
,
child:
Positioned
(
top:
8
,
left:
index
==
0
?
0
:
5.5
,
child:
Container
(
height:
75
,
width:
(
screenWidth
-
30
-
11
)
/
2
,
child:
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
7
),
child:
Image
.
asset
(
'assets/plan_compare_detail_info_bg.png'
,
fit:
BoxFit
.
cover
),
),
)),
Positioned
(
left:
12
,
top:
24
,
child:
baseText
(
planinfo
.
planName
,
15
,
Color
(
0xff333333
),
bold:
true
),
),
Positioned
(
left:
12
,
top:
48
,
child:
baseText
(
'¥'
+
planinfo
.
minPrice
+
'-'
+
planinfo
.
maxPrice
,
14
,
Colors
.
red
,
bold:
true
),
),
]));
),
Positioned
(
left:
12
,
top:
48
,
child:
baseText
(
'¥'
+
planinfo
.
minPrice
+
'-'
+
planinfo
.
maxPrice
,
14
,
Colors
.
red
,
bold:
true
),
),
]));
},
);
}
...
...
@@ -260,12 +245,14 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
return
Container
(
height:
170
,
child:
Row
(
children:
<
Widget
>[
Expanded
(
flex:
1
,
child:
planPopularityLeftItem
(
groups
.
plans
[
0
])),
Expanded
(
flex:
1
,
child:
planPopularityRightItem
(
groups
.
plans
[
1
]))
Expanded
(
flex:
1
,
child:
planPopularityLeftItem
(
groups
.
plans
[
0
],
groups
)),
Expanded
(
flex:
1
,
child:
planPopularityRightItem
(
groups
.
plans
[
1
],
groups
))
]));
}
Widget
planPopularityLeftItem
(
Plans
plan
)
{
Widget
planPopularityLeftItem
(
Plans
plan
,
Groups
groups
)
{
return
Container
(
height:
170
,
child:
Stack
(
children:
<
Widget
>[
...
...
@@ -317,7 +304,7 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
Positioned
(
right:
0
,
top:
0
,
width:
95
*
0.7
,
width:
95
*
sellCount
(
0
,
groups
.
plans
[
1
])
,
height:
7
,
child:
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
3.5
),
...
...
@@ -331,7 +318,7 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
]));
}
Widget
planPopularityRightItem
(
Plans
plan
)
{
Widget
planPopularityRightItem
(
Plans
plan
,
Groups
groups
)
{
return
Container
(
height:
170
,
child:
Stack
(
children:
<
Widget
>[
...
...
@@ -389,7 +376,7 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
Positioned
(
left:
0
,
top:
0
,
width:
95
*
0.3
,
width:
95
*
sellCount
(
1
,
groups
.
plans
[
0
])
,
height:
7
,
child:
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
3.5
),
...
...
@@ -460,4 +447,16 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
),
]));
}
double
sellCount
(
int
index
,
Plans
anotherPlans
)
{
Groups
popularity
=
_model
.
detailLive
.
data
.
second
[
0
];
Plans
plans
=
popularity
.
plans
[
index
];
int
salesCount
=
int
.
parse
(
plans
.
salesCount
);
int
anSalesCount
=
int
.
parse
(
plans
.
salesCount
);
if
(
salesCount
>=
anSalesCount
)
{
return
1.0
;
}
else
{
return
anSalesCount
/
salesCount
;
}
}
}
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