Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
life_module
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
flutter-plugin
life_module
Commits
6d6dc3e5
Commit
6d6dc3e5
authored
Oct 16, 2021
by
汪林玲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持null-safety
parent
88fe4c9a
Changes
56
Hide whitespace changes
Inline
Side-by-side
Showing
56 changed files
with
929 additions
and
925 deletions
+929
-925
lib/components/appraise_item.dart
lib/components/appraise_item.dart
+4
-4
lib/components/filter_area.dart
lib/components/filter_area.dart
+29
-29
lib/components/filter_panel.dart
lib/components/filter_panel.dart
+66
-66
lib/components/goods_item.dart
lib/components/goods_item.dart
+13
-13
lib/components/life_image.dart
lib/components/life_image.dart
+7
-7
lib/components/search_bar.dart
lib/components/search_bar.dart
+17
-17
lib/components/shop_class_nav.dart
lib/components/shop_class_nav.dart
+8
-8
lib/components/shop_item.dart
lib/components/shop_item.dart
+17
-17
lib/components/shop_list.dart
lib/components/shop_list.dart
+8
-8
lib/components/shop_type_nav.dart
lib/components/shop_type_nav.dart
+5
-5
lib/models/filter_model.dart
lib/models/filter_model.dart
+41
-39
lib/models/shop_list_model.dart
lib/models/shop_list_model.dart
+27
-27
lib/util/resource.dart
lib/util/resource.dart
+2
-2
lib/util/search_history_utils.dart
lib/util/search_history_utils.dart
+6
-6
lib/utils/buy_loading_dialog_utils.dart
lib/utils/buy_loading_dialog_utils.dart
+6
-6
lib/utils/filter_panel_utils.dart
lib/utils/filter_panel_utils.dart
+15
-15
lib/utils/share_dialog_utils.dart
lib/utils/share_dialog_utils.dart
+26
-26
lib/views/city/city.dart
lib/views/city/city.dart
+13
-13
lib/views/city/components/index.dart
lib/views/city/components/index.dart
+35
-35
lib/views/city/entity/city_model.dart
lib/views/city/entity/city_model.dart
+8
-9
lib/views/city/view.dart
lib/views/city/view.dart
+41
-40
lib/views/life/actions/action.dart
lib/views/life/actions/action.dart
+20
-20
lib/views/life/components/diamond_bit.dart
lib/views/life/components/diamond_bit.dart
+11
-11
lib/views/life/components/float_banner.dart
lib/views/life/components/float_banner.dart
+4
-4
lib/views/life/components/mini_banner.dart
lib/views/life/components/mini_banner.dart
+4
-4
lib/views/life/components/scroll_body.dart
lib/views/life/components/scroll_body.dart
+30
-30
lib/views/life/components/search_area.dart
lib/views/life/components/search_area.dart
+21
-21
lib/views/life/components/sec_kill.dart
lib/views/life/components/sec_kill.dart
+56
-56
lib/views/life/models/mini_banner_model.dart
lib/views/life/models/mini_banner_model.dart
+7
-7
lib/views/life/models/model.dart
lib/views/life/models/model.dart
+27
-25
lib/views/life/view.dart
lib/views/life/view.dart
+8
-8
lib/views/search/actions/action.dart
lib/views/search/actions/action.dart
+18
-18
lib/views/search/components/scroll_body.dart
lib/views/search/components/scroll_body.dart
+32
-32
lib/views/search/components/search_history.dart
lib/views/search/components/search_history.dart
+5
-5
lib/views/search/components/search_tips.dart
lib/views/search/components/search_tips.dart
+8
-8
lib/views/search/models/model.dart
lib/views/search/models/model.dart
+14
-14
lib/views/search/view.dart
lib/views/search/view.dart
+24
-28
lib/views/sec_kill/actions/action.dart
lib/views/sec_kill/actions/action.dart
+27
-27
lib/views/sec_kill/components/ad_banner.dart
lib/views/sec_kill/components/ad_banner.dart
+12
-12
lib/views/sec_kill/components/goods_items.dart
lib/views/sec_kill/components/goods_items.dart
+29
-29
lib/views/sec_kill/components/localtion_tips.dart
lib/views/sec_kill/components/localtion_tips.dart
+13
-13
lib/views/sec_kill/components/times.dart
lib/views/sec_kill/components/times.dart
+14
-14
lib/views/sec_kill/models/model.dart
lib/views/sec_kill/models/model.dart
+18
-16
lib/views/sec_kill/models/sec_kill_model.dart
lib/views/sec_kill/models/sec_kill_model.dart
+10
-10
lib/views/sec_kill/view.dart
lib/views/sec_kill/view.dart
+17
-16
lib/views/shop/actions/action.dart
lib/views/shop/actions/action.dart
+13
-13
lib/views/shop/components/appraise_items.dart
lib/views/shop/components/appraise_items.dart
+3
-3
lib/views/shop/components/footer_explain.dart
lib/views/shop/components/footer_explain.dart
+1
-1
lib/views/shop/components/goods_items.dart
lib/views/shop/components/goods_items.dart
+24
-24
lib/views/shop/components/nav_bar.dart
lib/views/shop/components/nav_bar.dart
+2
-2
lib/views/shop/components/recommend.dart
lib/views/shop/components/recommend.dart
+8
-8
lib/views/shop/components/shop_info.dart
lib/views/shop/components/shop_info.dart
+16
-16
lib/views/shop/models/model.dart
lib/views/shop/models/model.dart
+12
-11
lib/views/shop/models/outer_info_model.dart
lib/views/shop/models/outer_info_model.dart
+5
-5
lib/views/shop/view.dart
lib/views/shop/view.dart
+21
-21
pubspec.yaml
pubspec.yaml
+1
-1
No files found.
lib/components/appraise_item.dart
View file @
6d6dc3e5
...
...
@@ -16,7 +16,7 @@ class AppraiseItem extends StatelessWidget {
children:
[
Container
(
child:
Text
(
item
.
comment
,
item
.
comment
!
,
style:
TextStyle
(
color:
rgba
(
48
,
38
,
0
,
1
),
fontSize:
13
.
rpx
),
),
),
...
...
@@ -37,7 +37,7 @@ class _ScoreInfo extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
List
<
InlineSpan
>
widgets
=
[];
double
score
=
double
.
parse
(
item
.
star
);
double
score
=
double
.
parse
(
item
.
star
!
);
for
(
int
star
=
1
,
len
=
score
.
ceil
();
star
<=
len
;
star
++)
{
widgets
.
add
(
WidgetSpan
(
child:
Image
.
asset
(
...
...
@@ -72,7 +72,7 @@ class _ScoreInfo extends StatelessWidget {
child:
Text
.
rich
(
TextSpan
(
children:
widgets
)),
),
Container
(
child:
Text
(
double
.
parse
(
item
.
star
).
toStringAsFixed
(
1
),
child:
Text
(
double
.
parse
(
item
.
star
!
).
toStringAsFixed
(
1
),
style:
TextStyle
(
color:
rgba
(
255
,
128
,
0
,
1
),
fontSize:
14
.
rpx
,
...
...
@@ -81,7 +81,7 @@ class _ScoreInfo extends StatelessWidget {
),
Spacer
(),
Text
(
DateUtil
.
formatDateStr
(
item
.
createTime
,
format:
"yyyy-MM-dd HH:mm:ss"
),
DateUtil
.
formatDateStr
(
item
.
createTime
!
,
format:
"yyyy-MM-dd HH:mm:ss"
),
style:
TextStyle
(
color:
rgba
(
153
,
153
,
153
,
1
),
fontSize:
11
.
rpx
),
)
],
...
...
lib/components/filter_area.dart
View file @
6d6dc3e5
...
...
@@ -5,10 +5,10 @@ import 'package:mvp/mvp.dart';
import
'package:life_module/models/filter_model.dart'
;
class
FilterArea
extends
StatefulWidget
{
final
FilterModel
model
;
final
Function
(
bool
checked
)
onTap
;
final
Function
()
onChange
;
final
double
topOffset
;
final
FilterModel
?
model
;
final
Function
(
bool
checked
)
?
onTap
;
final
Function
()
?
onChange
;
final
double
?
topOffset
;
FilterArea
({
this
.
model
,
this
.
onTap
,
this
.
topOffset
,
this
.
onChange
});
@override
State
<
StatefulWidget
>
createState
()
=>
_FilterAreaState
();
...
...
@@ -16,7 +16,7 @@ class FilterArea extends StatefulWidget {
class
_FilterAreaState
extends
State
<
FilterArea
>
{
Function
()
_onChange
;
Function
()
?
_onChange
;
@override
void
initState
()
{
...
...
@@ -27,19 +27,19 @@ class _FilterAreaState extends State<FilterArea> {
@override
Widget
build
(
BuildContext
context
)
{
return
QMProvider
<
FilterModel
>.
value
(
model:
widget
.
model
,
model:
widget
.
model
!
,
builderWidget:
(
context
,
model
,
child
)
{
if
(
model
.
isEmpty
())
{
return
Container
(
height:
48
.
rpx
,
);
}
String
regionName
=
''
;
String
?
regionName
=
''
;
if
(
model
.
getCheckedTwoRegion
()
!=
null
&&
model
.
getCheckedTwoRegion
().
name
!=
null
)
{
regionName
=
model
.
getCheckedTwoRegion
().
name
;
model
.
getCheckedTwoRegion
()
!
.
name
!=
null
)
{
regionName
=
model
.
getCheckedTwoRegion
()
!
.
name
;
}
else
if
(
model
.
getCheckedOneRegion
()
!=
null
)
{
regionName
=
model
.
getCheckedOneRegion
().
name
;
regionName
=
model
.
getCheckedOneRegion
()
!
.
name
;
}
return
Container
(
height:
48
.
rpx
,
...
...
@@ -49,11 +49,11 @@ class _FilterAreaState extends State<FilterArea> {
child:
Row
(
children:
[
_FilterItem
(
text:
model
.
getCheckedOneCategory
().
name
,
text:
model
.
getCheckedOneCategory
()
!
.
name
,
checked:
model
.
getFilterAreaIndex
()
==
1
,
onTap:
(
checked
)
{
if
(
widget
.
onTap
!=
null
)
{
widget
.
onTap
(
checked
);
widget
.
onTap
!
(
checked
);
}
if
(
checked
)
{
return
;
...
...
@@ -62,8 +62,8 @@ class _FilterAreaState extends State<FilterArea> {
FilterPanelUtils
.
show
(
topOffset:
widget
.
topOffset
,
items:
model
.
getCategorys
(),
oneCheckedId:
model
.
getCheckedOneCategory
().
id
,
twoCheckedId:
model
.
getCheckedTwoCategory
().
id
,
oneCheckedId:
model
.
getCheckedOneCategory
()
!
.
id
,
twoCheckedId:
model
.
getCheckedTwoCategory
()
!
.
id
,
context:
context
,
model:
model
,
onClose:
()
{
...
...
@@ -74,7 +74,7 @@ class _FilterAreaState extends State<FilterArea> {
model
.
stFilterAreaIndex
(
0
);
model
.
setCheckedCategory
(
onwItem
,
twoItem
);
if
(
_onChange
!=
null
){
_onChange
();
_onChange
!
();
}
});
},
...
...
@@ -84,7 +84,7 @@ class _FilterAreaState extends State<FilterArea> {
checked:
model
.
getFilterAreaIndex
()
==
2
,
onTap:
(
checked
)
{
if
(
widget
.
onTap
!=
null
)
{
widget
.
onTap
(
checked
);
widget
.
onTap
!
(
checked
);
}
if
(
checked
)
{
return
;
...
...
@@ -93,8 +93,8 @@ class _FilterAreaState extends State<FilterArea> {
FilterPanelUtils
.
show
(
topOffset:
widget
.
topOffset
,
items:
model
.
getRegions
(),
oneCheckedId:
model
.
getCheckedOneRegion
().
id
,
twoCheckedId:
model
.
getCheckedTwoRegion
().
id
,
oneCheckedId:
model
.
getCheckedOneRegion
()
!
.
id
,
twoCheckedId:
model
.
getCheckedTwoRegion
()
!
.
id
,
context:
context
,
model:
model
,
onClose:
()
{
...
...
@@ -105,17 +105,17 @@ class _FilterAreaState extends State<FilterArea> {
model
.
stFilterAreaIndex
(
0
);
model
.
setCheckedRegion
(
onwItem
,
twoItem
);
if
(
_onChange
!=
null
){
_onChange
();
_onChange
!
();
}
});
},
),
_FilterItem
(
text:
model
.
getCheckedOneSort
().
name
,
text:
model
.
getCheckedOneSort
()
!
.
name
,
checked:
model
.
getFilterAreaIndex
()
==
3
,
onTap:
(
checked
)
{
if
(
widget
.
onTap
!=
null
)
{
widget
.
onTap
(
checked
);
widget
.
onTap
!
(
checked
);
}
if
(
checked
)
{
return
;
...
...
@@ -124,8 +124,8 @@ class _FilterAreaState extends State<FilterArea> {
FilterPanelUtils
.
show
(
topOffset:
widget
.
topOffset
,
items:
model
.
getSorts
(),
oneCheckedId:
model
.
getCheckedOneSort
().
id
,
twoCheckedId:
model
.
getCheckedTwoSort
().
id
,
oneCheckedId:
model
.
getCheckedOneSort
()
!
.
id
,
twoCheckedId:
model
.
getCheckedTwoSort
()
!
.
id
,
context:
context
,
model:
model
,
onClose:
()
{
...
...
@@ -136,7 +136,7 @@ class _FilterAreaState extends State<FilterArea> {
model
.
stFilterAreaIndex
(
0
);
model
.
setCheckedSort
(
onwItem
,
twoItem
);
if
(
_onChange
!=
null
){
_onChange
();
_onChange
!
();
}
});
},
...
...
@@ -151,8 +151,8 @@ class _FilterAreaState extends State<FilterArea> {
class
_FilterItem
extends
StatelessWidget
{
final
bool
checked
;
final
String
text
;
final
Function
(
bool
checked
)
onTap
;
final
String
?
text
;
final
Function
(
bool
checked
)
?
onTap
;
_FilterItem
({
this
.
text
,
this
.
onTap
,
this
.
checked
=
false
});
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -162,14 +162,14 @@ class _FilterItem extends StatelessWidget {
textColor
=
rgba
(
255
,
128
,
0
,
1
);
iconColor
=
textColor
;
}
String
clipText
=
text
;
String
clipText
=
text
!
;
if
(
clipText
.
length
>
5
)
{
clipText
=
"
${text.substring(0, 5)}
..."
;
clipText
=
"
${text
!
.substring(0, 5)}
..."
;
}
return
Expanded
(
child:
GestureDetector
(
onTap:
()
{
onTap
(
checked
);
onTap
!
(
checked
);
},
child:
Container
(
height:
48
.
rpx
,
...
...
lib/components/filter_panel.dart
View file @
6d6dc3e5
...
...
@@ -5,14 +5,14 @@ import 'package:life_repository/life_repository.dart';
import
'package:life_module/models/filter_model.dart'
;
class
FilterPanel
extends
StatelessWidget
{
final
FilterModel
model
;
final
List
<
FilterItemEntity
>
items
;
final
String
oneCheckedId
;
final
String
twoCheckedId
;
final
Function
()
onClose
;
final
double
topOffset
;
final
Function
()
onChange
;
final
Function
(
FilterItemEntity
onwItem
,
FilterItemEntity
twoItem
)
onConfirm
;
final
FilterModel
?
model
;
final
List
<
FilterItemEntity
>
?
items
;
final
String
?
oneCheckedId
;
final
String
?
twoCheckedId
;
final
Function
()
?
onClose
;
final
double
?
topOffset
;
final
Function
()
?
onChange
;
final
Function
(
FilterItemEntity
?
onwItem
,
FilterItemEntity
?
twoItem
)
onConfirm
;
FilterPanel
(
{
this
.
items
,
this
.
model
,
...
...
@@ -20,7 +20,7 @@ class FilterPanel extends StatelessWidget {
this
.
twoCheckedId
,
this
.
onClose
,
this
.
topOffset
,
this
.
onConfirm
,
required
this
.
onConfirm
,
this
.
onChange
,
});
@override
...
...
@@ -41,7 +41,7 @@ class FilterPanel extends StatelessWidget {
FilterArea
(
model:
model
,
onTap:
(
checked
)
{
onClose
();
onClose
!
();
},
onChange:
onChange
,
),
...
...
@@ -75,24 +75,24 @@ class FilterPanel extends StatelessWidget {
}
class
_Body
extends
StatefulWidget
{
final
String
oneCheckedId
;
final
String
twoCheckedId
;
final
List
<
FilterItemEntity
>
list
;
final
Function
(
FilterItemEntity
onwItem
,
FilterItemEntity
twoItem
)
onConfirm
;
_Body
({
this
.
list
,
this
.
oneCheckedId
,
this
.
twoCheckedId
,
this
.
onConfirm
});
final
String
?
oneCheckedId
;
final
String
?
twoCheckedId
;
final
List
<
FilterItemEntity
>
?
list
;
final
Function
(
FilterItemEntity
?
onwItem
,
FilterItemEntity
?
twoItem
)
onConfirm
;
_Body
({
this
.
list
,
this
.
oneCheckedId
,
this
.
twoCheckedId
,
required
this
.
onConfirm
});
@override
State
<
StatefulWidget
>
createState
()
=>
_BodyState
();
}
class
_BodyState
extends
State
<
_Body
>
{
String
oneCheckedId
=
''
;
String
twoCheckedId
=
''
;
FilterItemEntity
onwItem
;
FilterItemEntity
twoItem
;
List
<
FilterItemEntity
>
get
list
=>
widget
.
list
;
List
<
FilterItemEntity
>
get
twoList
{
FilterItemEntity
item
=
list
.
firstWhere
((
item
)
=>
item
.
id
==
oneCheckedId
);
if
(
item
!=
null
&&
item
.
subs
.
length
>
0
)
{
String
?
oneCheckedId
=
''
;
String
?
twoCheckedId
=
''
;
FilterItemEntity
?
onwItem
;
FilterItemEntity
?
twoItem
;
List
<
FilterItemEntity
>
?
get
list
=>
widget
.
list
;
List
<
FilterItemEntity
>
?
get
twoList
{
FilterItemEntity
item
=
list
!
.
firstWhere
((
item
)
=>
item
.
id
==
oneCheckedId
);
if
(
item
!=
null
&&
item
.
subs
!
.
length
>
0
)
{
return
item
.
subs
;
}
return
[];
...
...
@@ -100,9 +100,9 @@ class _BodyState extends State<_Body> {
// 是否需要二级
bool
get
isTwoLevel
{
for
(
int
i
=
0
,
len
=
list
.
length
;
i
<
len
;
i
++)
{
FilterItemEntity
item
=
list
[
i
];
if
(
item
.
subs
!=
null
&&
item
.
subs
.
length
>
0
)
{
for
(
int
i
=
0
,
len
=
list
!
.
length
;
i
<
len
;
i
++)
{
FilterItemEntity
item
=
list
!
[
i
];
if
(
item
.
subs
!=
null
&&
item
.
subs
!
.
length
>
0
)
{
return
true
;
}
}
...
...
@@ -114,9 +114,9 @@ class _BodyState extends State<_Body> {
super
.
initState
();
oneCheckedId
=
widget
.
oneCheckedId
;
twoCheckedId
=
widget
.
twoCheckedId
;
onwItem
=
list
.
firstWhere
((
item
)
=>
item
.
id
==
oneCheckedId
);
if
(
twoList
!=
null
&&
twoList
.
length
>
0
)
{
twoItem
=
twoList
.
firstWhere
((
item
)
=>
item
.
id
==
twoCheckedId
);
onwItem
=
list
!
.
firstWhere
((
item
)
=>
item
.
id
==
oneCheckedId
);
if
(
twoList
!=
null
&&
twoList
!
.
length
>
0
)
{
twoItem
=
twoList
!
.
firstWhere
((
item
)
=>
item
.
id
==
twoCheckedId
);
}
}
...
...
@@ -163,15 +163,15 @@ class _BodyState extends State<_Body> {
return
;
}
onwItem
=
item
;
if
(
onwItem
.
subs
!=
null
&&
onwItem
.
subs
.
length
>
0
)
{
twoItem
=
onwItem
.
subs
[
0
];
if
(
onwItem
!
.
subs
!=
null
&&
onwItem
!.
subs
!
.
length
>
0
)
{
twoItem
=
onwItem
!.
subs
!
[
0
];
}
else
{
twoItem
=
FilterItemEntity
(
null
,
null
,
[]);
}
setState
(()
{
oneCheckedId
=
item
.
id
;
twoCheckedId
=
twoItem
.
id
;
twoCheckedId
=
twoItem
!
.
id
;
});
},
),
...
...
@@ -194,17 +194,17 @@ class _BodyState extends State<_Body> {
),
_Fotter
(
onReset:
()
{
FilterItemEntity
onwItem
=
list
[
0
];
FilterItemEntity
onwItem
=
list
!
[
0
];
FilterItemEntity
twoItem
;
if
(
onwItem
.
subs
!=
null
&&
onwItem
.
subs
.
length
>
0
)
{
twoItem
=
onwItem
.
subs
[
0
];
if
(
onwItem
.
subs
!=
null
&&
onwItem
.
subs
!
.
length
>
0
)
{
twoItem
=
onwItem
.
subs
!
[
0
];
}
else
{
twoItem
=
FilterItemEntity
(
null
,
null
,
[]);
}
widget
.
onConfirm
(
onwItem
,
twoItem
);
widget
.
onConfirm
!
(
onwItem
,
twoItem
);
},
onConfirm:
()
{
widget
.
onConfirm
(
onwItem
,
twoItem
);
widget
.
onConfirm
!
(
onwItem
,
twoItem
);
},
),
],
...
...
@@ -218,13 +218,13 @@ class _BodyState extends State<_Body> {
/// 一级选择列表
class
_OneLevel
extends
StatelessWidget
{
final
String
checkedId
;
final
List
<
FilterItemEntity
>
list
;
final
Function
(
FilterItemEntity
item
)
onTap
;
final
String
?
checkedId
;
final
List
<
FilterItemEntity
>
?
list
;
final
Function
(
FilterItemEntity
item
)
?
onTap
;
_OneLevel
({
this
.
list
,
this
.
checkedId
,
this
.
onTap
});
@override
Widget
build
(
BuildContext
context
)
{
int
len
=
list
.
length
;
int
len
=
list
!
.
length
;
return
Container
(
width:
94
.
rpx
,
child:
ListView
.
builder
(
...
...
@@ -235,18 +235,18 @@ class _OneLevel extends StatelessWidget {
int
preIndex
=
i
-
1
;
// 下一个索引
int
nextIndex
=
i
+
1
;
FilterItemEntity
item
=
list
[
i
];
FilterItemEntity
item
=
list
!
[
i
];
bool
checked
=
item
.
id
==
checkedId
;
bool
preChecked
=
preIndex
>
-
1
&&
list
[
preIndex
].
id
==
checkedId
;
bool
preChecked
=
preIndex
>
-
1
&&
list
!
[
preIndex
].
id
==
checkedId
;
bool
nextChecked
=
nextIndex
<
len
-
1
&&
list
[
nextIndex
].
id
==
checkedId
;
nextIndex
<
len
-
1
&&
list
!
[
nextIndex
].
id
==
checkedId
;
return
_OneLevelTextItem
(
text:
item
.
name
,
checked:
checked
,
nextChecked:
nextChecked
,
preChecked:
preChecked
,
onTap:
()
{
onTap
(
item
);
onTap
!
(
item
);
},
);
}),
...
...
@@ -256,13 +256,13 @@ class _OneLevel extends StatelessWidget {
/// 二级选择列表
class
_TwoLevel
extends
StatelessWidget
{
final
String
checkedId
;
final
List
<
FilterItemEntity
>
list
;
final
Function
(
FilterItemEntity
item
)
onTap
;
final
String
?
checkedId
;
final
List
<
FilterItemEntity
>
?
list
;
final
Function
(
FilterItemEntity
item
)
?
onTap
;
_TwoLevel
({
this
.
list
,
this
.
checkedId
,
this
.
onTap
});
@override
Widget
build
(
BuildContext
context
)
{
if
(
list
==
null
||
list
.
length
==
0
)
{
if
(
list
==
null
||
list
!
.
length
==
0
)
{
return
Container
();
}
return
Expanded
(
...
...
@@ -271,17 +271,17 @@ class _TwoLevel extends StatelessWidget {
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount
(
crossAxisCount:
2
,
childAspectRatio:
3.1818181818181817
),
itemBuilder:
(
context
,
i
)
{
FilterItemEntity
item
=
list
[
i
];
FilterItemEntity
item
=
list
!
[
i
];
bool
checked
=
item
.
id
==
checkedId
;
return
_TextItem
(
text:
item
.
name
,
checked:
checked
,
onTap:
()
{
onTap
(
item
);
onTap
!
(
item
);
},
);
},
itemCount:
list
.
length
,
itemCount:
list
!
.
length
,
),
);
}
...
...
@@ -289,23 +289,23 @@ class _TwoLevel extends StatelessWidget {
/// 排序选择列表
class
_SortLevel
extends
StatelessWidget
{
final
String
checkedId
;
final
List
<
FilterItemEntity
>
list
;
final
Function
(
FilterItemEntity
item
)
onTap
;
final
String
?
checkedId
;
final
List
<
FilterItemEntity
>
?
list
;
final
Function
(
FilterItemEntity
item
)
?
onTap
;
_SortLevel
({
this
.
list
,
this
.
checkedId
,
this
.
onTap
});
@override
Widget
build
(
BuildContext
context
)
{
List
<
Widget
>
childs
=
[];
List
<
Widget
>
rows
=
[];
for
(
int
i
=
0
,
len
=
list
.
length
;
i
<
len
;
i
++)
{
FilterItemEntity
item
=
list
[
i
];
for
(
int
i
=
0
,
len
=
list
!
.
length
;
i
<
len
;
i
++)
{
FilterItemEntity
item
=
list
!
[
i
];
bool
checked
=
item
.
id
==
checkedId
;
Widget
widget
=
_TextItem
(
text:
item
.
name
,
checked:
checked
,
onTap:
()
{
onTap
(
item
);
onTap
!
(
item
);
},
);
rows
.
add
(
Container
(
...
...
@@ -332,11 +332,11 @@ class _SortLevel extends StatelessWidget {
/// 一级选择文字
class
_OneLevelTextItem
extends
StatelessWidget
{
final
String
text
;
final
String
?
text
;
final
bool
checked
;
final
bool
preChecked
;
final
bool
nextChecked
;
final
Function
()
onTap
;
final
Function
()
?
onTap
;
_OneLevelTextItem
(
{
this
.
text
,
this
.
onTap
,
...
...
@@ -368,9 +368,9 @@ class _OneLevelTextItem extends StatelessWidget {
/// 二级选择文字
class
_TextItem
extends
StatelessWidget
{
final
String
text
;
final
String
?
text
;
final
bool
checked
;
final
Function
()
onTap
;
final
Function
()
?
onTap
;
_TextItem
({
this
.
text
,
this
.
onTap
,
this
.
checked
=
false
});
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -385,7 +385,7 @@ class _TextItem extends StatelessWidget {
height:
44
.
rpx
,
alignment:
Alignment
.
center
,
child:
Text
(
text
,
text
!
,
style:
TextStyle
(
color:
color
,
fontSize:
13
.
rpx
),
),
));
...
...
@@ -394,8 +394,8 @@ class _TextItem extends StatelessWidget {
/// 底部操作按钮
class
_Fotter
extends
StatelessWidget
{
final
Function
()
onReset
;
final
Function
()
onConfirm
;
final
Function
()
?
onReset
;
final
Function
()
?
onConfirm
;
_Fotter
({
this
.
onReset
,
this
.
onConfirm
});
@override
Widget
build
(
BuildContext
context
)
{
...
...
lib/components/goods_item.dart
View file @
6d6dc3e5
...
...
@@ -5,8 +5,8 @@ import 'package:life_repository/life_repository.dart';
import
'package:common_module/widget/xiaoxiong_base_image_widget/widget.dart'
;
class
GoodsItem
extends
StatelessWidget
{
final
ComboItem
item
;
final
Function
()
onTap
;
final
ComboItem
?
item
;
final
Function
()
?
onTap
;
GoodsItem
({
this
.
item
,
this
.
onTap
});
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -28,7 +28,7 @@ class GoodsItem extends StatelessWidget {
height:
74
.
rpx
,
width:
74
.
rpx
,
child:
XiaoxiongBaseImageWidget
(
imageUrl:
item
.
shopImg
,
imageUrl:
item
!.
shopImg
!
,
height:
74
.
rpx
,
width:
74
.
rpx
,
),
...
...
@@ -61,7 +61,7 @@ class GoodsItem extends StatelessWidget {
//、 标题
class
_Title
extends
StatelessWidget
{
final
ComboItem
item
;
final
ComboItem
?
item
;
_Title
(
this
.
item
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -70,7 +70,7 @@ class _Title extends StatelessWidget {
child:
Row
(
children:
[
TypeIcon
(
type:
int
.
parse
(
item
.
dealType
),
type:
int
.
parse
(
item
!.
dealType
!
),
),
SizedBox
(
width:
5
.
rpx
,
...
...
@@ -78,7 +78,7 @@ class _Title extends StatelessWidget {
Expanded
(
child:
Container
(
child:
Text
(
item
.
itemTitle
,
item
!.
itemTitle
!
,
overflow:
TextOverflow
.
ellipsis
,
maxLines:
1
,
style:
TextStyle
(
...
...
@@ -93,7 +93,7 @@ class _Title extends StatelessWidget {
/// 价格信息
class
_PriceInfo
extends
StatelessWidget
{
final
ComboItem
item
;
final
ComboItem
?
item
;
_PriceInfo
(
this
.
item
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -111,7 +111,7 @@ class _PriceInfo extends StatelessWidget {
),
),
Text
(
item
.
endPrice
,
item
!.
endPrice
!
,
style:
TextStyle
(
color:
rgba
(
255
,
4
,
0
,
1
),
fontSize:
16
.
rpx
,
...
...
@@ -121,7 +121,7 @@ class _PriceInfo extends StatelessWidget {
width:
4
.
rpx
,
),
Text
(
"¥
${item.originalPrice}
"
,
"¥
${item
!
.originalPrice}
"
,
style:
TextStyle
(
color:
rgba
(
153
,
153
,
153
,
1
),
fontSize:
12
.
rpx
,
...
...
@@ -139,7 +139,7 @@ class _PriceInfo extends StatelessWidget {
topRight:
Radius
.
circular
(
9
.
rpx
),
bottomRight:
Radius
.
circular
(
9
.
rpx
))),
child:
Text
(
item
.
userCommissionText
,
item
!.
userCommissionText
!
,
style:
TextStyle
(
color:
rgba
(
255
,
128
,
0
,
1
),
fontSize:
11
.
rpx
,
height:
1.2
),
),
...
...
@@ -152,7 +152,7 @@ class _PriceInfo extends StatelessWidget {
/// 定位信息
class
_LocaionInfo
extends
StatelessWidget
{
final
ComboItem
item
;
final
ComboItem
?
item
;
_LocaionInfo
(
this
.
item
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -165,7 +165,7 @@ class _LocaionInfo extends StatelessWidget {
Container
(
constraints:
BoxConstraints
(
maxWidth:
190
.
rpx
),
child:
Text
(
item
.
shopTitle
,
item
!.
shopTitle
!
,
maxLines:
1
,
overflow:
TextOverflow
.
ellipsis
,
style:
TextStyle
(
...
...
@@ -182,7 +182,7 @@ class _LocaionInfo extends StatelessWidget {
),*/
Spacer
(),
Text
(
item
.
distance
,
item
!.
distance
!
,
style:
TextStyle
(
color:
rgba
(
102
,
102
,
102
,
1
),
fontSize:
11
.
rpx
,
height:
1.2
),
),
...
...
lib/components/life_image.dart
View file @
6d6dc3e5
import
'package:flutter/material.dart'
;
class
LifeImage
extends
StatelessWidget
{
final
String
name
;
final
double
width
;
final
double
height
;
final
Color
color
;
final
BoxFit
fit
;
final
String
?
name
;
final
double
?
width
;
final
double
?
height
;
final
Color
?
color
;
final
BoxFit
?
fit
;
LifeImage
({
Key
key
,
Key
?
key
,
this
.
name
,
this
.
width
,
this
.
height
,
...
...
@@ -17,7 +17,7 @@ class LifeImage extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
return
Image
.
asset
(
name
,
name
!
,
key:
key
,
width:
width
,
height:
height
,
...
...
lib/components/search_bar.dart
View file @
6d6dc3e5
...
...
@@ -2,12 +2,12 @@ import 'package:flutter/material.dart';
import
'package:common_module/utils/xapp_utils.dart'
;
class
SearchBar
extends
StatefulWidget
{
final
Color
inputColor
;
final
Color
?
inputColor
;
final
bool
enabled
;
final
FocusNode
focusNode
;
final
Function
(
String
)
onSubmitted
;
final
Function
(
String
)
onChanged
;
final
TextEditingController
controller
;
final
FocusNode
?
focusNode
;
final
Function
(
String
)
?
onSubmitted
;
final
Function
(
String
)
?
onChanged
;
final
TextEditingController
?
controller
;
SearchBar
(
{
this
.
enabled
=
false
,
this
.
inputColor
,
...
...
@@ -42,7 +42,7 @@ class _SearchBarState extends State<SearchBar> {
:
InkWell
(
child:
_Button
(),
onTap:
()
{
widget
.
onSubmitted
(
widget
.
controller
.
text
);
widget
.
onSubmitted
!(
widget
.
controller
!
.
text
);
},
),
SizedBox
(
...
...
@@ -55,11 +55,11 @@ class _SearchBarState extends State<SearchBar> {
}
class
_TextField
extends
StatefulWidget
{
final
bool
enabled
;
final
FocusNode
focusNode
;
final
Function
(
String
)
onSubmitted
;
final
Function
(
String
)
onChanged
;
final
TextEditingController
controller
;
final
bool
?
enabled
;
final
FocusNode
?
focusNode
;
final
Function
(
String
)
?
onSubmitted
;
final
Function
(
String
)
?
onChanged
;
final
TextEditingController
?
controller
;
_TextField
(
{
this
.
enabled
,
this
.
focusNode
,
...
...
@@ -78,9 +78,9 @@ class _TextFieldState extends State<_TextField> {
void
initState
()
{
super
.
initState
();
if
(
widget
.
controller
!=
null
)
{
widget
.
controller
.
addListener
(()
{
widget
.
controller
!
.
addListener
(()
{
setState
(()
{
showCloseBtn
=
widget
.
controller
.
text
.
isNotEmpty
;
showCloseBtn
=
widget
.
controller
!
.
text
.
isNotEmpty
;
});
});
}
...
...
@@ -163,10 +163,10 @@ class _TextFieldState extends State<_TextField> {
top:
0
,
child:
InkWell
(
onTap:
()
{
widget
.
onChanged
(
""
);
widget
.
onSubmitted
(
""
);
widget
.
controller
.
text
=
''
;
widget
.
focusNode
.
requestFocus
();
widget
.
onChanged
!
(
""
);
widget
.
onSubmitted
!
(
""
);
widget
.
controller
!
.
text
=
''
;
widget
.
focusNode
!
.
requestFocus
();
},
child:
Container
(
width:
34
.
rpx
,
...
...
lib/components/shop_class_nav.dart
View file @
6d6dc3e5
...
...
@@ -6,8 +6,8 @@ import 'package:life_module/models/filter_model.dart';
import
'package:life_repository/life_repository.dart'
;
class
ShopClassNav
extends
StatefulWidget
{
final
FilterModel
model
;
final
Function
()
onChange
;
final
FilterModel
?
model
;
final
Function
()
?
onChange
;
ShopClassNav
({
this
.
model
,
this
.
onChange
});
@override
State
<
StatefulWidget
>
createState
()
=>
_ShopClassNavState
();
...
...
@@ -23,14 +23,14 @@ class _ShopClassNavState extends State<ShopClassNav>
@override
Widget
build
(
BuildContext
context
)
{
return
QMProvider
<
FilterModel
>.
value
(
model:
widget
.
model
,
model:
widget
.
model
!
,
builderWidget:
(
context
,
model
,
child
)
{
if
(
model
.
isEmpty
())
{
return
Container
(
height:
40
.
rpx
,
);
}
List
<
FilterItemEntity
>
subs
=
model
.
getCheckedOneCategory
()
.
subs
;
List
<
FilterItemEntity
>
subs
=
model
.
getCheckedOneCategory
()
!.
subs
!
;
return
Container
(
key:
ValueKey
(
subs
.
map
((
e
)
=>
e
.
id
).
join
(
'_'
)),
...
...
@@ -40,7 +40,7 @@ class _ShopClassNavState extends State<ShopClassNav>
child:
NotificationListener
(
child:
NavigationBar
(
controller:
model
.
getShopClassNavTabController
(),
items:
subs
.
map
((
e
)
=>
e
.
name
).
toList
(),
items:
subs
.
map
((
e
)
=>
e
.
name
).
toList
()
as
List
<
String
>?
,
selectColor:
rgba
(
255
,
128
,
0
,
1
),
normalColor:
rgba
(
102
,
102
,
102
,
1
),
selectStyle:
TextStyle
(
...
...
@@ -51,18 +51,18 @@ class _ShopClassNavState extends State<ShopClassNav>
),
isScrollable:
true
,
onChange:
(
index
)
{
if
(
subs
[
index
]
==
model
.
getCheckedTwoCategory
())
{
if
(
subs
[
index
!
]
==
model
.
getCheckedTwoCategory
())
{
return
;
}
model
.
setCheckedCategory
(
model
.
getCheckedOneCategory
(),
subs
[
index
]);
widget
.
onChange
();
widget
.
onChange
!
();
},
indicatorSize:
TabBarIndicatorSize
.
label
,
indicator:
RoundRectIndicator
(
color:
Colors
.
transparent
,
height:
0
,
marginBottom:
0
),
),
onNotification:
(
e
)
{
onNotification:
(
dynamic
e
)
{
return
true
;
},
),
...
...
lib/components/shop_item.dart
View file @
6d6dc3e5
...
...
@@ -5,8 +5,8 @@ import 'package:life_repository/life_repository.dart';
import
'package:common_module/widget/xiaoxiong_base_image_widget/widget.dart'
;
class
ShopItem
extends
StatelessWidget
{
final
RestaurantItem
item
;
final
Function
()
onTap
;
final
RestaurantItem
?
item
;
final
Function
()
?
onTap
;
ShopItem
({
this
.
item
,
this
.
onTap
});
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -30,7 +30,7 @@ class ShopItem extends StatelessWidget {
height:
74
.
rpx
,
width:
74
.
rpx
,
child:
XiaoxiongBaseImageWidget
(
imageUrl:
item
.
shopImg
,
imageUrl:
item
!.
shopImg
!
,
height:
74
.
rpx
,
width:
74
.
rpx
,
),
...
...
@@ -67,7 +67,7 @@ class ShopItem extends StatelessWidget {
/// 标题
class
_Title
extends
StatelessWidget
{
final
RestaurantItem
item
;
final
RestaurantItem
?
item
;
_Title
(
this
.
item
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -78,7 +78,7 @@ class _Title extends StatelessWidget {
Expanded
(
child:
Container
(
child:
Text
(
item
.
shopTitle
,
item
!.
shopTitle
!
,
overflow:
TextOverflow
.
ellipsis
,
maxLines:
1
,
style:
TextStyle
(
...
...
@@ -93,11 +93,11 @@ class _Title extends StatelessWidget {
/// 评分和销量信息
class
_ScoreInfo
extends
StatelessWidget
{
final
RestaurantItem
item
;
final
RestaurantItem
?
item
;
_ScoreInfo
(
this
.
item
);
@override
Widget
build
(
BuildContext
context
)
{
var
showStarScore
=
item
.
showStarScore
;
var
showStarScore
=
item
!.
showStarScore
!
;
List
<
InlineSpan
>
widgets
=
[];
double
score
=
double
.
parse
(
showStarScore
);
for
(
int
star
=
1
,
len
=
score
.
ceil
();
star
<=
len
;
star
++)
{
...
...
@@ -123,7 +123,7 @@ class _ScoreInfo extends StatelessWidget {
width:
2
.
rpx
,
)));
widgets
.
add
(
TextSpan
(
text:
double
.
parse
(
item
.
commentScore
).
toStringAsFixed
(
1
),
text:
double
.
parse
(
item
!.
commentScore
!
).
toStringAsFixed
(
1
),
style:
TextStyle
(
color:
rgba
(
255
,
128
,
0
,
1
),
fontSize:
14
.
rpx
,
...
...
@@ -147,7 +147,7 @@ class _ScoreInfo extends StatelessWidget {
),
Spacer
(),
Text
(
"¥
${item.avgPrice}
/人"
,
"¥
${item
!
.avgPrice}
/人"
,
style:
TextStyle
(
color:
rgba
(
102
,
102
,
102
,
1
),
fontSize:
11
.
rpx
),
)
],
...
...
@@ -158,7 +158,7 @@ class _ScoreInfo extends StatelessWidget {
/// 地址信息
class
_LocaionInfo
extends
StatelessWidget
{
final
RestaurantItem
item
;
final
RestaurantItem
?
item
;
_LocaionInfo
(
this
.
item
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -168,12 +168,12 @@ class _LocaionInfo extends StatelessWidget {
child:
Row
(
children:
[
Text
(
item
.
categoryName
,
item
!.
categoryName
!
,
style:
TextStyle
(
color:
rgba
(
102
,
102
,
102
,
1
),
fontSize:
11
.
rpx
),
),
Spacer
(),
Text
(
"
${item
.regionName}
|
${item
.distance}
"
,
"
${item
!.regionName}
|
${item!
.distance}
"
,
style:
TextStyle
(
color:
rgba
(
102
,
102
,
102
,
1
),
fontSize:
11
.
rpx
),
)
],
...
...
@@ -183,11 +183,11 @@ class _LocaionInfo extends StatelessWidget {
}
class
_GoodList
extends
StatelessWidget
{
final
RestaurantItem
item
;
final
RestaurantItem
?
item
;
_GoodList
(
this
.
item
);
@override
Widget
build
(
BuildContext
context
)
{
List
<
Widget
>
items
=
item
.
itemList
.
map
((
e
)
{
List
<
Widget
>
items
=
item
!.
itemList
!
.
map
((
e
)
{
return
_GoodItem
(
e
);
}).
toList
();
return
Container
(
...
...
@@ -210,7 +210,7 @@ class _GoodItem extends StatelessWidget {
child:
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
[
TypeIcon
(
type:
int
.
parse
(
item
.
dealType
)),
TypeIcon
(
type:
int
.
parse
(
item
.
dealType
!
)),
SizedBox
(
width:
6
.
rpx
,
),
...
...
@@ -221,7 +221,7 @@ class _GoodItem extends StatelessWidget {
Expanded
(
child:
Container
(
child:
Text
(
item
.
itemTitle
,
item
.
itemTitle
!
,
overflow:
TextOverflow
.
ellipsis
,
maxLines:
1
,
style:
TextStyle
(
color:
rgba
(
51
,
51
,
51
,
1
),
fontSize:
12
.
rpx
),
...
...
@@ -252,7 +252,7 @@ class _PriceInfo extends StatelessWidget {
),
),
Text
(
item
.
endPrice
,
item
.
endPrice
!
,
style:
TextStyle
(
color:
rgba
(
255
,
4
,
0
,
1
),
fontSize:
14
.
rpx
,
...
...
lib/components/shop_list.dart
View file @
6d6dc3e5
...
...
@@ -8,18 +8,18 @@ import 'package:common_module/utils/list_model_status_utils.dart';
import
'package:common_module/utils/xapp_utils.dart'
;
class
ShopList
extends
StatelessWidget
{
final
ShopListModel
model
;
final
Function
(
ShopItemEntity
)
onTap
;
final
Function
()
onReset
;
final
ShopListModel
?
model
;
final
Function
(
ShopItemEntity
)
?
onTap
;
final
Function
()
?
onReset
;
ShopList
({
this
.
model
,
this
.
onTap
,
this
.
onReset
});
@override
Widget
build
(
BuildContext
context
)
{
return
SliverPadding
(
padding:
EdgeInsets
.
zero
,
sliver:
QMProvider
<
ShopListModel
>.
value
(
model:
model
,
model:
model
!
,
builderWidget:
(
context
,
model
,
child
)
{
Widget
statusWidget
=
ListModelStatusUtils
.
getInstance
()
.
form
(
Widget
?
statusWidget
=
ListModelStatusUtils
.
getInstance
()!
.
form
(
failText:
"没有搜到结果~"
,
btnText:
"恢复默认"
,
paddingTop:
30
.
rpx
,
...
...
@@ -43,19 +43,19 @@ class ShopList extends StatelessWidget {
return
SliverList
(
delegate:
SliverChildBuilderDelegate
(
(
BuildContext
context
,
int
index
)
{
var
item
=
model
.
getList
()[
index
];
ShopItemEntity
item
=
model
.
getList
()[
index
];
if
(
item
.
type
==
0
)
{
return
ShopItem
(
item:
item
.
restaurant
,
onTap:
()
{
onTap
(
item
);
onTap
!
(
item
);
},
);
}
return
GoodsItem
(
item:
item
.
combo
,
onTap:
()
{
onTap
(
item
);
onTap
!
(
item
);
},
);
},
...
...
lib/components/shop_type_nav.dart
View file @
6d6dc3e5
...
...
@@ -5,13 +5,13 @@ import 'package:life_module/models/filter_model.dart';
import
'package:mvp/mvp.dart'
;
class
ShopTypeNav
extends
StatelessWidget
{
final
FilterModel
model
;
final
Function
()
onChange
;
final
FilterModel
?
model
;
final
Function
()
?
onChange
;
ShopTypeNav
({
this
.
model
,
this
.
onChange
});
@override
Widget
build
(
BuildContext
context
)
{
return
QMProvider
<
FilterModel
>.
value
(
model:
model
,
model:
model
!
,
builderWidget:
(
context
,
model
,
child
)
{
if
(
model
.
isEmpty
())
{
return
Container
(
...
...
@@ -25,7 +25,7 @@ class ShopTypeNav extends StatelessWidget {
color:
rgba
(
245
,
245
,
245
,
1
),
child:
DefaultTabController
(
length:
2
,
initialIndex:
model
.
getShopTypeNavIndex
(),
initialIndex:
model
.
getShopTypeNavIndex
()
!
,
child:
NavigationBar
(
items:
[
"优惠店铺"
,
"优惠套餐"
],
selectColor:
rgba
(
48
,
38
,
0
,
1
),
...
...
@@ -46,7 +46,7 @@ class ShopTypeNav extends StatelessWidget {
marginBottom:
6
.
rpx
),
onChange:
(
index
)
{
model
.
setShopTypeNavIndex
(
index
);
onChange
();
onChange
!
();
},
),
),
...
...
lib/models/filter_model.dart
View file @
6d6dc3e5
import
'dart:async'
;
import
'package:flutter/material.dart'
;
import
'package:mvp/mvp.dart'
;
...
...
@@ -8,45 +10,45 @@ class FilterModel extends BaseModel {
List
<
FilterItemEntity
>
_categorys
=
[];
List
<
FilterItemEntity
>
_sorts
=
[];
FilterItemEntity
_checkedOneRegion
;
FilterItemEntity
_checkedOneCategory
;
FilterItemEntity
_checkedOneSort
;
FilterItemEntity
?
_checkedOneRegion
;
FilterItemEntity
?
_checkedOneCategory
;
FilterItemEntity
?
_checkedOneSort
;
FilterItemEntity
_checkedTwoRegion
;
FilterItemEntity
_checkedTwoCategory
;
FilterItemEntity
_checkedTwoSort
;
FilterItemEntity
?
_checkedTwoRegion
;
FilterItemEntity
?
_checkedTwoCategory
;
FilterItemEntity
?
_checkedTwoSort
;
// 筛选区域选中的索引
int
_filterAreaIndex
=
0
;
// 二级类目控制器
TabController
_shopClassNavTabController
;
int
_shopTypeNavIndex
=
0
;
TabController
?
_shopClassNavTabController
;
int
?
_shopTypeNavIndex
=
0
;
// 搜索关键词
String
_keywords
;
String
?
_keywords
;
Future
<
void
>
getFilterList
(
String
cid
)
async
{
FilterObject
object
=
await
FilterArepository
.
get
().
getFilterList
(
cid
);
FilterObject
object
=
await
(
FilterArepository
.
get
().
getFilterList
(
cid
)
as
FutureOr
<
FilterObject
>
);
_regions
=
object
.
regions
;
_categorys
=
object
.
categorys
;
_sorts
=
object
.
sorts
;
if
(
_regions
.
length
>
0
)
{
_checkedOneRegion
=
_regions
[
0
];
if
(
_checkedOneRegion
.
subs
.
length
>
0
)
{
_checkedTwoRegion
=
_checkedOneRegion
.
subs
[
0
];
if
(
_checkedOneRegion
!.
subs
!
.
length
>
0
)
{
_checkedTwoRegion
=
_checkedOneRegion
!.
subs
!
[
0
];
}
}
if
(
_categorys
.
length
>
0
)
{
_checkedOneCategory
=
_categorys
[
0
];
if
(
_checkedOneCategory
.
subs
.
length
>
0
)
{
_checkedTwoCategory
=
_checkedOneCategory
.
subs
[
0
];
if
(
_checkedOneCategory
!.
subs
!
.
length
>
0
)
{
_checkedTwoCategory
=
_checkedOneCategory
!.
subs
!
[
0
];
_shopClassNavTabController
=
TabController
(
length:
_checkedOneCategory
.
subs
.
length
,
vsync:
ScrollableState
());
length:
_checkedOneCategory
!.
subs
!
.
length
,
vsync:
ScrollableState
());
}
}
if
(
_sorts
.
length
>
0
)
{
_checkedOneSort
=
_sorts
[
0
];
if
(
_checkedOneSort
.
subs
.
length
>
0
)
{
_checkedTwoSort
=
_checkedOneSort
.
subs
[
0
];
if
(
_checkedOneSort
!.
subs
!
.
length
>
0
)
{
_checkedTwoSort
=
_checkedOneSort
!.
subs
!
[
0
];
}
}
...
...
@@ -66,7 +68,7 @@ class FilterModel extends BaseModel {
notifyListeners
();
}
FilterItemEntity
getCheckedOneRegion
()
{
FilterItemEntity
?
getCheckedOneRegion
()
{
return
_checkedOneRegion
;
}
...
...
@@ -76,17 +78,17 @@ class FilterModel extends BaseModel {
notifyListeners
();
}
FilterItemEntity
getCheckedOneCategory
()
{
FilterItemEntity
?
getCheckedOneCategory
()
{
return
_checkedOneCategory
;
}
void
setCheckedCategory
(
FilterItemEntity
c1
,
FilterItemEntity
c2
)
{
void
setCheckedCategory
(
FilterItemEntity
?
c1
,
FilterItemEntity
c2
)
{
var
oldCheckedOneCategory
=
_checkedOneCategory
;
_checkedOneCategory
=
c1
;
_checkedTwoCategory
=
c2
;
int
index
=
0
;
if
(
c2
!=
null
&&
c1
.
subs
.
length
>
0
)
{
index
=
c1
.
subs
.
indexWhere
((
item
)
=>
item
.
id
==
c2
.
id
);
if
(
c2
!=
null
&&
c1
!.
subs
!
.
length
>
0
)
{
index
=
c1
.
subs
!
.
indexWhere
((
item
)
=>
item
.
id
==
c2
.
id
);
}
if
(
c1
!=
oldCheckedOneCategory
)
{
int
oIndex
=
0
;
...
...
@@ -96,21 +98,21 @@ class FilterModel extends BaseModel {
}
_shopClassNavTabController
=
TabController
(
length:
c1
.
subs
.
length
,
length:
c1
!.
subs
!
.
length
,
initialIndex:
oIndex
,
vsync:
ScrollableState
());
notifyListeners
();
Future
.
delayed
(
Duration
(
milliseconds:
300
)).
then
((
value
)
{
_shopClassNavTabController
.
animateTo
(
index
);
_shopClassNavTabController
!
.
animateTo
(
index
);
});
}
else
{
_shopClassNavTabController
.
animateTo
(
index
);
_shopClassNavTabController
!
.
animateTo
(
index
);
}
}
void
resetShopClassNavController
()
{}
FilterItemEntity
getCheckedOneSort
()
{
FilterItemEntity
?
getCheckedOneSort
()
{
return
_checkedOneSort
;
}
...
...
@@ -120,18 +122,18 @@ class FilterModel extends BaseModel {
notifyListeners
();
}
FilterItemEntity
getCheckedTwoRegion
()
{
FilterItemEntity
?
getCheckedTwoRegion
()
{
if
(
_checkedTwoRegion
==
null
)
{
return
FilterItemEntity
(
null
,
null
,
[]);
}
return
_checkedTwoRegion
;
}
FilterItemEntity
getCheckedTwoCategory
()
{
FilterItemEntity
?
getCheckedTwoCategory
()
{
return
_checkedTwoCategory
;
}
FilterItemEntity
getCheckedTwoSort
()
{
FilterItemEntity
?
getCheckedTwoSort
()
{
if
(
_checkedTwoSort
==
null
)
{
return
FilterItemEntity
(
null
,
null
,
[]);
}
...
...
@@ -150,19 +152,19 @@ class FilterModel extends BaseModel {
return
_sorts
;
}
TabController
getShopClassNavTabController
()
{
TabController
?
getShopClassNavTabController
()
{
return
_shopClassNavTabController
;
}
int
getShopTypeNavIndex
()
{
int
?
getShopTypeNavIndex
()
{
return
_shopTypeNavIndex
;
}
void
setShopTypeNavIndex
(
int
index
)
{
void
setShopTypeNavIndex
(
int
?
index
)
{
_shopTypeNavIndex
=
index
;
}
String
getKeywords
()
{
String
?
getKeywords
()
{
return
_keywords
;
}
...
...
@@ -174,8 +176,8 @@ class FilterModel extends BaseModel {
if
(
_regions
.
length
>
0
)
{
FilterItemEntity
onwItem
=
_regions
[
0
];
FilterItemEntity
twoItem
;
if
(
onwItem
.
subs
!=
null
&&
onwItem
.
subs
.
length
>
0
)
{
twoItem
=
onwItem
.
subs
[
0
];
if
(
onwItem
.
subs
!=
null
&&
onwItem
.
subs
!
.
length
>
0
)
{
twoItem
=
onwItem
.
subs
!
[
0
];
}
else
{
twoItem
=
FilterItemEntity
(
null
,
null
,
[]);
}
...
...
@@ -185,8 +187,8 @@ class FilterModel extends BaseModel {
if
(
_categorys
.
length
>
0
)
{
FilterItemEntity
onwItem
=
_categorys
[
0
];
FilterItemEntity
twoItem
;
if
(
onwItem
.
subs
!=
null
&&
onwItem
.
subs
.
length
>
0
)
{
twoItem
=
onwItem
.
subs
[
0
];
if
(
onwItem
.
subs
!=
null
&&
onwItem
.
subs
!
.
length
>
0
)
{
twoItem
=
onwItem
.
subs
!
[
0
];
}
else
{
twoItem
=
FilterItemEntity
(
null
,
null
,
[]);
}
...
...
@@ -196,8 +198,8 @@ class FilterModel extends BaseModel {
if
(
_sorts
.
length
>
0
)
{
FilterItemEntity
onwItem
=
_sorts
[
0
];
FilterItemEntity
twoItem
;
if
(
onwItem
.
subs
!=
null
&&
onwItem
.
subs
.
length
>
0
)
{
twoItem
=
onwItem
.
subs
[
0
];
if
(
onwItem
.
subs
!=
null
&&
onwItem
.
subs
!
.
length
>
0
)
{
twoItem
=
onwItem
.
subs
!
[
0
];
}
else
{
twoItem
=
FilterItemEntity
(
null
,
null
,
[]);
}
...
...
lib/models/shop_list_model.dart
View file @
6d6dc3e5
...
...
@@ -2,16 +2,16 @@ import 'package:mvp/mvp.dart';
import
'package:life_repository/life_repository.dart'
;
class
ShopListModel
extends
BaseListModel
<
ShopItemEntity
>
{
String
_cityId
;
String
_lat
;
String
_lng
;
String
_firstCateId
;
String
?
_cityId
;
String
?
_lat
;
String
?
_lng
;
String
?
_firstCateId
;
String
_keywords
=
''
;
String
_secondCateId
;
String
_regionId
;
String
_sortType
;
late
String
_secondCateId
;
String
?
_regionId
;
String
?
_sortType
;
// 0 优惠店铺,1 优惠套餐
int
_shopTypeNavIndex
=
0
;
int
?
_shopTypeNavIndex
=
0
;
@override
Future
<
List
<
ShopItemEntity
>>
request
()
{
...
...
@@ -21,41 +21,41 @@ class ShopListModel extends BaseListModel<ShopItemEntity> {
Future
<
List
<
ShopItemEntity
>>
_find
()
{
if
(
_shopTypeNavIndex
==
0
)
{
return
ShopListRepository
.
get
().
findRestaurantList
(
_cityId
,
_lat
,
_lng
,
_cityId
!
,
_lat
!
,
_lng
!
,
getPage
().
toString
(),
_firstCateId
,
_firstCateId
!
,
_keywords
,
_secondCateId
,
_regionId
,
_sortType
);
_regionId
!
,
_sortType
!
);
}
return
ShopListRepository
.
get
().
findComboList
(
_cityId
,
_lat
,
_lng
,
_cityId
!
,
_lat
!
,
_lng
!
,
getPage
().
toString
(),
_firstCateId
,
_firstCateId
!
,
_keywords
,
_secondCateId
,
_regionId
,
_sortType
);
_regionId
!
,
_sortType
!
);
}
void
setCityId
(
String
cid
)
{
void
setCityId
(
String
?
cid
)
{
_cityId
=
cid
;
}
void
setLat
(
String
lat
)
{
void
setLat
(
String
?
lat
)
{
_lat
=
lat
;
}
void
setLng
(
String
lng
)
{
void
setLng
(
String
?
lng
)
{
_lng
=
lng
;
}
void
setFirstCateId
(
String
firstCateId
)
{
void
setFirstCateId
(
String
?
firstCateId
)
{
_firstCateId
=
firstCateId
;
}
...
...
@@ -71,15 +71,15 @@ class ShopListModel extends BaseListModel<ShopItemEntity> {
_secondCateId
=
secondCateId
;
}
void
setRegionId
(
String
regionId
)
{
void
setRegionId
(
String
?
regionId
)
{
_regionId
=
regionId
;
}
void
setSortType
(
String
sortType
)
{
void
setSortType
(
String
?
sortType
)
{
_sortType
=
sortType
;
}
void
setShopTypeNavIndex
(
int
index
)
{
void
setShopTypeNavIndex
(
int
?
index
)
{
_shopTypeNavIndex
=
index
;
}
}
lib/util/resource.dart
View file @
6d6dc3e5
...
...
@@ -33,12 +33,12 @@ class Res {
/// 转换定位数据
/// [entity] 当前获取到的定位数据
///
static
Future
<
LocationEntity
>
convertLocation
({
LocationEntity
entity
,
String
location
})
async
{
static
Future
<
LocationEntity
>
convertLocation
({
LocationEntity
?
entity
,
String
?
location
})
async
{
dynamic
idata
=
await
AMapRepository
.
get
().
geocodeAddress
(
key:
Res
.
aWebMapKey
,
location:
location
);
if
(
idata
[
'status'
]
==
'1'
&&
idata
[
'regeocode'
]
!=
null
){
if
(
idata
[
'regeocode'
]
!=
null
){
idata
=
idata
[
'regeocode'
];
entity
.
address
=
idata
[
'formatted_address'
];
entity
!
.
address
=
idata
[
'formatted_address'
];
if
(
idata
[
'addressComponent'
]
!=
null
){
idata
=
idata
[
'addressComponent'
];
entity
.
city
=
idata
[
'city'
];
...
...
lib/util/search_history_utils.dart
View file @
6d6dc3e5
import
'package:common_module/utils/store_utils.dart'
;
class
SearchHistoryUtils
{
static
SearchHistoryUtils
_instance
;
static
SearchHistoryUtils
getInstance
()
{
static
SearchHistoryUtils
?
_instance
;
static
SearchHistoryUtils
?
getInstance
()
{
if
(
_instance
==
null
)
{
_instance
=
new
SearchHistoryUtils
();
}
...
...
@@ -15,7 +15,7 @@ class SearchHistoryUtils {
if
(
s
==
null
||
s
.
isEmpty
)
{
return
;
}
var
words
=
StoreUtils
.
getInstance
().
getForKey
(
var
words
=
StoreUtils
.
getInstance
()
!
.
getForKey
(
key:
key
,
defaultValue:
[]
);
...
...
@@ -27,11 +27,11 @@ class SearchHistoryUtils {
if
(
words
.
length
>
20
)
{
words
=
words
.
sublist
(
0
,
20
);
}
StoreUtils
.
getInstance
().
setKV
(
key:
key
,
value:
words
);
StoreUtils
.
getInstance
()
!
.
setKV
(
key:
key
,
value:
words
);
}
List
<
String
>
getWords
()
{
var
words
=
StoreUtils
.
getInstance
().
getForKey
(
var
words
=
StoreUtils
.
getInstance
()
!
.
getForKey
(
key:
key
,
);
if
(
words
==
null
)
{
...
...
@@ -41,6 +41,6 @@ class SearchHistoryUtils {
}
void
clear
()
{
StoreUtils
.
getInstance
().
setKV
(
key:
key
,
value:
[]);
StoreUtils
.
getInstance
()
!
.
setKV
(
key:
key
,
value:
[]);
}
}
lib/utils/buy_loading_dialog_utils.dart
View file @
6d6dc3e5
...
...
@@ -4,9 +4,9 @@ import 'package:common_module/utils/xapp_utils.dart';
import
'package:life_module/components/life_image.dart'
;
class
BuyLoadingDialogUtils
{
static
BuyLoadingDialogUtils
_instance
;
static
BuyLoadingDialogUtils
?
_instance
;
static
BuyLoadingDialogUtils
getInstance
()
{
static
BuyLoadingDialogUtils
?
getInstance
()
{
if
(
_instance
==
null
)
{
_instance
=
new
BuyLoadingDialogUtils
.
_
();
}
...
...
@@ -21,14 +21,14 @@ class BuyLoadingDialogUtils {
}
class
LoadingDialog
{
Route
route
;
Route
?
route
;
LoadingDialog
()
{
route
=
_LoadingDialogRouter
(
_LoadingDialog
());
BoostNavigator
.
instance
.
appState
.
topContainer
.
navigator
.
push
(
route
);
BoostNavigator
.
instance
.
appState
!.
topContainer
!.
navigator
!.
push
(
route
!
);
}
void
close
()
{
if
(
route
!=
null
&&
route
.
navigator
!=
null
)
{
route
.
navigator
.
pop
(
route
);
if
(
route
!=
null
&&
route
!
.
navigator
!=
null
)
{
route
!.
navigator
!
.
pop
(
route
);
}
}
}
...
...
lib/utils/filter_panel_utils.dart
View file @
6d6dc3e5
...
...
@@ -4,20 +4,20 @@ import 'package:life_repository/life_repository.dart';
import
'package:life_module/models/filter_model.dart'
;
class
FilterPanelUtils
{
static
OverlayEntry
overlayEntry
;
static
OverlayEntry
?
overlayEntry
;
static
show
({
@
required
BuildContext
context
,
@
required
FilterModel
model
,
@
required
List
<
FilterItemEntity
>
items
,
@required
String
oneCheckedId
,
Function
()
onChange
,
double
topOffset
,
String
twoCheckedId
,
Function
()
onClose
,
Function
(
FilterItemEntity
onwItem
,
FilterItemEntity
twoItem
)
onConfirm
,
required
BuildContext
context
,
required
FilterModel
model
,
required
List
<
FilterItemEntity
>
items
,
required
String
?
oneCheckedId
,
Function
()
?
onChange
,
double
?
topOffset
,
String
?
twoCheckedId
,
Function
()
?
onClose
,
Function
(
FilterItemEntity
onwItem
,
FilterItemEntity
twoItem
)
?
onConfirm
,
})
{
close
();
OverlayState
overlayState
=
Overlay
.
of
(
context
);
OverlayState
overlayState
=
Overlay
.
of
(
context
)
!
;
overlayEntry
=
new
OverlayEntry
(
builder:
(
context
)
{
return
FilterPanel
(
...
...
@@ -28,21 +28,21 @@ class FilterPanelUtils {
twoCheckedId:
twoCheckedId
,
onClose:
()
{
close
();
onClose
();
onClose
!
();
},
onConfirm:
(
onwItem
,
twoItem
)
{
close
();
onConfirm
(
onwItem
,
twoItem
);
onConfirm
!(
onwItem
!,
twoItem
!
);
},
onChange:
onChange
,
);
});
overlayState
.
insert
(
overlayEntry
);
overlayState
.
insert
(
overlayEntry
!
);
}
static
void
close
()
{
if
(
overlayEntry
!=
null
)
{
overlayEntry
.
remove
();
overlayEntry
!
.
remove
();
overlayEntry
=
null
;
}
}
...
...
lib/utils/share_dialog_utils.dart
View file @
6d6dc3e5
...
...
@@ -20,23 +20,23 @@ import 'package:common_module/utils/system_share_utils.dart';
import
'package:common_module/utils/clipboard_utils.dart'
;
class
ShareDialogUtils
{
static
ShareDialogUtils
_instance
;
static
ShareDialogUtils
getInstance
()
{
static
ShareDialogUtils
?
_instance
;
static
ShareDialogUtils
?
getInstance
()
{
if
(
_instance
==
null
)
{
_instance
=
new
ShareDialogUtils
();
}
return
_instance
;
}
void
show
({
BuildContext
context
,
ShopInfo
shopInfo
,
String
firstCateId
})
{
void
show
({
required
BuildContext
context
,
ShopInfo
?
shopInfo
,
String
?
firstCateId
})
{
var
route
=
_LoadingDialogRouter
(
_Dialog
(
shopInfo
,
firstCateId
));
Navigator
.
of
(
context
).
push
(
route
);
}
}
class
_Dialog
extends
StatefulWidget
{
final
ShopInfo
shopInfo
;
final
String
firstCateId
;
final
ShopInfo
?
shopInfo
;
final
String
?
firstCateId
;
_Dialog
(
this
.
shopInfo
,
this
.
firstCateId
);
@override
State
<
StatefulWidget
>
createState
()
=>
_DialogState
();
...
...
@@ -49,8 +49,8 @@ class _DialogState extends State<_Dialog> {
_Item
(
2
,
"assets/wechat2.png"
,
"微信好友"
)
];
GlobalKey
globalKey
=
GlobalKey
();
String
shareUrl
;
ShopInfo
get
shopInfo
=>
widget
.
shopInfo
;
String
?
shareUrl
;
ShopInfo
?
get
shopInfo
=>
widget
.
shopInfo
;
@override
void
initState
()
{
...
...
@@ -59,8 +59,8 @@ class _DialogState extends State<_Dialog> {
}
void
getShareUrl
()
async
{
String
url
=
await
ShopInfoRepository
.
get
()
.
getShareUrl
(
widget
.
shopInfo
.
shopId
,
widget
.
firstCateId
);
String
?
url
=
await
ShopInfoRepository
.
get
()
.
getShareUrl
(
widget
.
shopInfo
!.
shopId
!,
widget
.
firstCateId
!
);
setState
(()
{
shareUrl
=
url
;
});
...
...
@@ -97,10 +97,10 @@ class _DialogState extends State<_Dialog> {
FlutterNativeToast
.
showToast
(
'请稍后'
);
return
;
}
String
copyText
=
'''店铺名称:
${shopInfo.shopTitle}
评分:
${shopInfo.commentScore}
人均:
${shopInfo.avgPrice}
地址:
${shopInfo.address}
String
copyText
=
'''店铺名称:
${shopInfo
!
.shopTitle}
评分:
${shopInfo
!
.commentScore}
人均:
${shopInfo
!
.avgPrice}
地址:
${shopInfo
!
.address}
——————————————————
$shareUrl
'''
;
...
...
@@ -111,34 +111,34 @@ $shareUrl
if
(
e
.
id
==
0
)
{
var
_permission
=
Platform
.
isIOS
?
Permission
.
photos
:
Permission
.
storage
;
var
permission
=
await
PermissionUtils
.
getInstance
()
var
permission
=
await
PermissionUtils
.
getInstance
()
!
.
has
(
permissions:
[
_permission
]);
var
status
=
permission
[
_permission
];
if
(
status
!=
PermissionUtilsStatus
.
granted
)
{
bool
confirm
=
await
Modal
.
showModal
(
bool
confirm
=
await
(
Modal
.
showModal
(
title:
"温馨提示"
,
msg:
"为给您提供更好的服务,使用此功能前需获取您的储存权限"
,
cancelBtnText:
'拒绝'
,
confirmBtnText:
'同意'
);
confirmBtnText:
'同意'
)
as
FutureOr
<
bool
>)
;
if
(!
confirm
)
{
return
;
}
if
(
status
==
PermissionUtilsStatus
.
permanentlyDenied
)
{
PermissionUtils
.
getInstance
().
openAppSetting
();
PermissionUtils
.
getInstance
()
!
.
openAppSetting
();
return
;
}
permission
=
await
PermissionUtils
.
getInstance
()
permission
=
await
PermissionUtils
.
getInstance
()
!
.
request
(
permissions:
[
_permission
]);
status
=
permission
[
_permission
];
if
(
status
!=
PermissionUtilsStatus
.
granted
)
{
return
;
}
}
await
FlutterAlbumSave
.
saveImageToAlbum
(
file
.
path
,
null
);
await
FlutterAlbumSave
.
saveImageToAlbum
(
file
.
path
,
'小熊有好货'
);
Navigator
.
of
(
context
).
pop
();
}
else
{
SystemShareUtils
.
getInstance
().
shareImage
(
file
.
path
);
SystemShareUtils
.
getInstance
()
!
.
shareImage
(
file
.
path
);
}
}
else
{
Navigator
.
of
(
context
).
pop
();
...
...
@@ -174,7 +174,7 @@ $shareUrl
height:
222
.
rpx
,
width:
222
.
rpx
,
child:
CachedNetworkImage
(
imageUrl:
widget
.
shopInfo
.
shopImg
,
imageUrl:
widget
.
shopInfo
!.
shopImg
!
,
height:
222
.
rpx
,
width:
222
.
rpx
,
fit:
BoxFit
.
cover
,
...
...
@@ -186,7 +186,7 @@ $shareUrl
Container
(
alignment:
Alignment
.
centerLeft
,
child:
Text
(
widget
.
shopInfo
.
shopTitle
,
widget
.
shopInfo
!.
shopTitle
!
,
style:
TextStyle
(
color:
rgba
(
48
,
38
,
0
,
1
),
fontSize:
12
.
rpx
,
...
...
@@ -218,7 +218,7 @@ $shareUrl
);
}
return
QrImage
(
data:
shareUrl
,
data:
shareUrl
!
,
version:
QrVersions
.
auto
,
size:
84
.
rpx
,
padding:
EdgeInsets
.
zero
,
...
...
@@ -359,9 +359,9 @@ $shareUrl
Future
<
File
>
widgetToImage
()
async
{
Completer
completer
=
Completer
<
File
>();
RenderRepaintBoundary
render
=
globalKey
.
currentContext
.
findRenderObject
()
;
RenderRepaintBoundary
render
=
globalKey
.
currentContext
!.
findRenderObject
()
as
RenderRepaintBoundary
;
ui
.
Image
image
=
await
render
.
toImage
(
pixelRatio:
2.0
);
ByteData
byteData
=
await
image
.
toByteData
(
format:
ui
.
ImageByteFormat
.
png
);
ByteData
byteData
=
await
(
image
.
toByteData
(
format:
ui
.
ImageByteFormat
.
png
)
as
FutureOr
<
ByteData
>
);
var
imgData
=
byteData
.
buffer
.
asUint8List
();
String
sTempDir
=
(
await
getTemporaryDirectory
()).
path
;
bool
isDirExist
=
await
Directory
(
sTempDir
).
exists
();
...
...
@@ -372,7 +372,7 @@ $shareUrl
File
file
=
File
(
sTempDir
+
"/widget_image_
$time
.png"
);
file
=
await
file
.
writeAsBytes
(
imgData
,
mode:
FileMode
.
writeOnly
,
flush:
true
);
completer
.
complete
(
file
);
return
completer
.
future
;
return
completer
.
future
as
FutureOr
<
File
>
;
}
}
...
...
lib/views/city/city.dart
View file @
6d6dc3e5
...
...
@@ -11,8 +11,8 @@ import 'package:azlistview/azlistview.dart';
import
'entity/city_model.dart'
;
class
CityPage
extends
StatefulWidget
{
final
Map
<
String
,
dynamic
>
param
;
const
CityPage
({
Key
key
,
this
.
param
})
:
super
(
key:
key
);
final
Map
<
String
,
dynamic
>
?
param
;
const
CityPage
({
Key
?
key
,
this
.
param
})
:
super
(
key:
key
);
@override
_CityPageState
createState
()
=>
_CityPageState
();
...
...
@@ -21,18 +21,18 @@ class CityPage extends StatefulWidget {
class
_CityPageState
extends
State
<
CityPage
>
{
List
<
CityModel
>
citysList
=
List
<
CityModel
>.
empty
(
growable:
true
);
ValueNotifier
<
SearchCityInfo
>
listenable
=
ValueNotifier
<
SearchCityInfo
>(
null
);
ValueNotifier
<
SearchCityInfo
?
>
listenable
=
ValueNotifier
<
SearchCityInfo
?
>(
null
);
String
_currentCity
=
''
;
String
?
_currentCity
=
''
;
@override
void
initState
()
{
super
.
initState
();
if
(
widget
.
param
!=
null
&&
widget
.
param
[
'currentCity'
]
!=
null
)
{
_currentCity
=
widget
.
param
[
'currentCity'
]
as
String
;
if
(
widget
.
param
!=
null
&&
widget
.
param
!
[
'currentCity'
]
!=
null
)
{
_currentCity
=
widget
.
param
![
'currentCity'
]
as
String
?
;
}
if
(
_currentCity
.
isNotEmpty
)
{
if
(
_currentCity
!
.
isNotEmpty
)
{
citysList
.
add
(
CityModel
(
type:
0
,
...
...
@@ -62,12 +62,12 @@ class _CityPageState extends State<CityPage> {
});
}
void
_handleList
({
@
required
List
<
CityModel
>
list
})
{
void
_handleList
({
required
List
<
CityModel
>
list
})
{
if
(
list
.
isEmpty
)
return
;
for
(
int
i
=
0
,
length
=
list
.
length
;
i
<
length
;
i
++)
{
CityModel
model
=
list
[
i
];
if
(
model
.
type
==
-
1
)
{
String
pinyin
=
model
.
namePinyin
;
String
pinyin
=
model
.
namePinyin
!
;
String
tag
=
pinyin
.
substring
(
0
,
1
).
toUpperCase
();
list
[
i
].
namePinyin
=
pinyin
;
if
(
RegExp
(
'[A-Z]'
).
hasMatch
(
tag
))
{
...
...
@@ -91,7 +91,7 @@ class _CityPageState extends State<CityPage> {
backgroundColor:
Color
(
0xFFF5F5F5
),
appBar:
buildAppBar
(
title:
'选择城市'
,
onPressed:
(){
NavigateUtils
.
pop
(
arguments:
{});
}),
})
as
PreferredSizeWidget
?
,
body:
_buildBody
(),
);
}
...
...
@@ -111,7 +111,7 @@ class _CityPageState extends State<CityPage> {
Expanded
(
child:
buildAzListViewWidget
(
notifier:
listenable
,
onCityTap:
(
String
city
)
{
onCityTap:
(
String
?
city
)
{
NavigateUtils
.
pop
(
arguments:
{
'city'
:
city
});
},
reEnteTap:
()
{
...
...
@@ -127,7 +127,7 @@ class _CityPageState extends State<CityPage> {
void
onChangedText
(
String
text
)
{
Iterable
<
CityModel
>
citys
=
citysList
.
where
((
ele
)
=>
(
ele
.
type
==
0
||
ele
.
name
.
indexOf
(
text
)
>
-
1
));
.
where
((
ele
)
=>
(
ele
.
type
==
0
||
ele
.
name
!
.
indexOf
(
text
)
>
-
1
));
listenable
.
value
=
SearchCityInfo
(
isSearch:
text
.
isNotEmpty
,
citys:
List
<
CityModel
>.
from
(
citys
),
...
...
lib/views/city/components/index.dart
View file @
6d6dc3e5
...
...
@@ -6,7 +6,7 @@ import 'package:life_module/util/resource.dart';
import
'package:life_module/views/city/entity/city_model.dart'
;
import
'package:common_module/utils/xapp_utils.dart'
;
Widget
buildAppBar
(
{
String
title
=
''
,
void
Function
()
onPressed
})
{
Widget
buildAppBar
(
{
String
title
=
''
,
void
Function
()
?
onPressed
})
{
return
AppBar
(
backgroundColor:
Colors
.
white
,
elevation:
0.1
,
...
...
@@ -38,14 +38,14 @@ Widget buildAppBar({String title = '',void Function() onPressed}) {
/// [onCityTap] 点击提交
///
Widget
buildSearchWidget
(
{
String
city
,
String
hintText
,
void
Function
(
String
)
onChanged
,
void
Function
(
String
)
onSubmitted
,
void
Function
()
onCityTap
,
void
Function
()
onEnterCity
,
String
?
city
,
String
?
hintText
,
void
Function
(
String
)
?
onChanged
,
void
Function
(
String
)
?
onSubmitted
,
void
Function
()
?
onCityTap
,
void
Function
()
?
onEnterCity
,
bool
enabled
=
true
,
TextEditingController
controller
,
TextEditingController
?
controller
,
})
{
Widget
_child
=
Container
(
decoration:
BoxDecoration
(
...
...
@@ -125,7 +125,7 @@ Widget buildSearchWidget({
child:
_child
,
),
onTap:
()
{
onEnterCity
();
onEnterCity
!
();
},
);
}
...
...
@@ -135,12 +135,12 @@ Widget buildSearchWidget({
///
///
Widget
buildLocationsWidget
(
{
@
required
String
title
,
@
required
Widget
action
,
required
String
title
,
required
Widget
action
,
bool
isLoading
=
false
,
List
<
dynamic
>
list
=
const
[],
Widget
bottom
,
void
Function
(
Map
<
String
,
dynamic
>)
onAddressTap
,
List
<
dynamic
>
?
list
=
const
[],
Widget
?
bottom
,
void
Function
(
Map
<
String
,
dynamic
>)
?
onAddressTap
,
EdgeInsetsGeometry
padding
=
const
EdgeInsets
.
symmetric
(
horizontal:
13
),
})
{
if
(
list
==
null
||
list
.
isEmpty
)
{
...
...
@@ -204,7 +204,7 @@ Widget buildLocationsWidget({
),
color:
Colors
.
white
,
),
onTap:
()
=>
onAddressTap
(
data
),
onTap:
()
=>
onAddressTap
!
(
data
),
);
},
),
...
...
@@ -213,7 +213,7 @@ Widget buildLocationsWidget({
);
}
Widget
buildCurrentLocationsWidget
(
{
String
title
=
''
,
void
Function
()
onTap
})
{
Widget
buildCurrentLocationsWidget
(
{
String
title
=
''
,
void
Function
()
?
onTap
})
{
return
InkWell
(
onTap:
onTap
,
child:
Container
(
...
...
@@ -247,10 +247,10 @@ Widget buildCurrentLocationsWidget({String title = '', void Function() onTap}) {
///
///
Widget
buildCityWidget
(
{
@required
List
<
String
>
citys
,
required
List
<
String
?
>
citys
,
bool
current
=
false
,
EdgeInsetsGeometry
padding
=
const
EdgeInsets
.
only
(
left:
13
),
void
Function
(
String
)
onCityTap
,
void
Function
(
String
)
?
onCityTap
,
})
{
return
GridView
.
builder
(
padding:
EdgeInsets
.
symmetric
(
...
...
@@ -267,7 +267,7 @@ Widget buildCityWidget({
childAspectRatio:
3.1
,
),
itemBuilder:
(
BuildContext
context
,
int
index
)
{
String
city
=
citys
[
index
];
String
city
=
citys
[
index
]
!
;
Widget
_child
=
Text
(
city
,
style:
TextStyle
(
color:
Color
(
0xFF302600
),
fontSize:
13
),
...
...
@@ -308,14 +308,14 @@ Widget buildCityWidget({
///
///
Widget
buildAzListViewWidget
(
{
@required
ValueNotifier
<
SearchCityInfo
>
notifier
,
@required
Function
(
String
)
onCityTap
,
@
required
Function
()
reEnteTap
,
required
ValueNotifier
<
SearchCityInfo
?
>
notifier
,
required
Function
(
String
?
)
onCityTap
,
required
Function
()
reEnteTap
,
})
{
return
ValueListenableBuilder
(
valueListenable:
notifier
,
builder:
(
BuildContext
context
,
SearchCityInfo
cityInfo
,
Widget
child
)
{
if
(
cityInfo
.
isSearch
&&
cityInfo
.
citys
.
length
==
1
)
{
builder:
(
BuildContext
context
,
SearchCityInfo
?
cityInfo
,
Widget
?
child
)
{
if
(
cityInfo
!.
isSearch
!
&&
cityInfo
.
citys
!
.
length
==
1
)
{
return
Column
(
children:
[
Container
(
...
...
@@ -330,7 +330,7 @@ Widget buildAzListViewWidget({
),
),
buildCityWidget
(
citys:
cityInfo
.
citys
[
0
].
citys
,
citys:
cityInfo
.
citys
![
0
].
citys
!
,
current:
true
,
onCityTap:
onCityTap
,
),
...
...
@@ -380,29 +380,29 @@ Widget buildAzListViewWidget({
);
}
return
AzListView
(
data:
cityInfo
.
citys
,
itemCount:
cityInfo
.
citys
.
length
,
data:
cityInfo
.
citys
!
,
itemCount:
cityInfo
.
citys
!
.
length
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
CityModel
model
=
cityInfo
.
citys
[
index
];
CityModel
model
=
cityInfo
.
citys
!
[
index
];
if
(
model
.
type
==
0
)
{
//0当前城市
return
buildCityWidget
(
citys:
model
.
citys
,
citys:
model
.
citys
!
,
current:
true
,
onCityTap:
onCityTap
,
);
}
else
if
(
model
.
type
==
1
)
{
//热门城市
return
buildCityWidget
(
citys:
model
.
citys
,
citys:
model
.
citys
!
,
current:
false
,
onCityTap:
onCityTap
,
);
}
Text
textWidget
;
if
(
cityInfo
.
isSearch
)
{
List
<
TextSpan
>
childs
=
model
.
name
.
split
(
""
).
map
((
s
)
{
if
(
cityInfo
.
isSearch
!
)
{
List
<
TextSpan
>
childs
=
model
.
name
!
.
split
(
""
).
map
((
s
)
{
bool
isKeyWordChar
=
cityInfo
.
keywords
.
indexOf
(
s
)
>
-
1
;
return
TextSpan
(
text:
s
,
...
...
@@ -419,7 +419,7 @@ Widget buildAzListViewWidget({
);
}
else
{
textWidget
=
Text
(
model
.
name
,
model
.
name
!
,
style:
TextStyle
(
color:
Color
(
0xFF302600
),
fontSize:
13
),
);
}
...
...
@@ -428,7 +428,7 @@ Widget buildAzListViewWidget({
child:
Container
(
color:
Colors
.
white
,
margin:
EdgeInsets
.
only
(
top:
(
cityInfo
.
isSearch
&&
index
==
1
)
?
12
:
0
,
top:
(
cityInfo
.
isSearch
!
&&
index
==
1
)
?
12
:
0
,
),
child:
Column
(
children:
[
...
...
@@ -450,7 +450,7 @@ Widget buildAzListViewWidget({
);
},
susItemBuilder:
(
BuildContext
context
,
int
index
)
{
CityModel
model
=
cityInfo
.
citys
[
index
];
CityModel
model
=
cityInfo
.
citys
!
[
index
];
if
(
model
.
type
==
0
)
{
return
Container
(
padding:
EdgeInsets
.
only
(
left:
13.0
),
...
...
lib/views/city/entity/city_model.dart
View file @
6d6dc3e5
import
'package:azlistview/azlistview.dart'
;
import
'package:flutter/foundation.dart'
;
class
SearchCityInfo
{
List
<
CityModel
>
citys
;
bool
isSearch
=
false
;
List
<
CityModel
>
?
citys
;
bool
?
isSearch
=
false
;
String
keywords
;
SearchCityInfo
({
this
.
citys
,
...
...
@@ -17,14 +16,14 @@ class SearchCityInfo {
/// type = 1 热门城市
///
class
CityModel
extends
ISuspensionBean
{
String
name
;
String
tagIndex
;
String
namePinyin
;
String
?
name
;
String
?
tagIndex
;
String
?
namePinyin
;
int
type
=
-
1
;
List
<
String
>
citys
;
List
<
String
?>?
citys
;
CityModel
({
@
required
this
.
name
,
required
this
.
name
,
this
.
tagIndex
,
this
.
namePinyin
,
this
.
type
=
-
1
,
...
...
@@ -36,5 +35,5 @@ class CityModel extends ISuspensionBean {
namePinyin
=
json
[
'pinyin'
];
@override
String
getSuspensionTag
()
=>
tagIndex
;
String
getSuspensionTag
()
=>
tagIndex
!
;
}
lib/views/city/view.dart
View file @
6d6dc3e5
import
'dart:async'
;
import
'dart:io'
;
import
'package:amaps_location/location.dart'
;
...
...
@@ -16,23 +17,23 @@ import 'package:modal/modal.dart';
import
'package:common_module/utils/loading_dialog_utils.dart'
;
class
LifeLocationPage
extends
StatefulWidget
{
final
Map
<
String
,
dynamic
>
param
;
const
LifeLocationPage
({
Key
key
,
this
.
param
})
:
super
(
key:
key
);
final
Map
<
String
,
dynamic
>
?
param
;
const
LifeLocationPage
({
Key
?
key
,
this
.
param
})
:
super
(
key:
key
);
@override
_LifeLocationPageState
createState
()
=>
_LifeLocationPageState
();
}
class
_LifeLocationPageState
extends
State
<
LifeLocationPage
>
{
///当前城市
String
_currentCity
;
String
_mCurrentCity
;
List
<
dynamic
>
_historyLocations
;
String
?
_currentCity
;
String
?
_mCurrentCity
;
List
<
dynamic
>
?
_historyLocations
;
//附近位置
List
<
dynamic
>
_nearbyLocations
=
List
<
dynamic
>.
empty
(
growable:
true
);
List
<
MapTipEntity
>
_searchTips
;
List
<
MapTipEntity
>
?
_searchTips
;
LocationEntity
_currentLocationEntity
;
LocationEntity
?
_currentLocationEntity
;
@override
...
...
@@ -48,7 +49,7 @@ class _LifeLocationPageState extends State<LifeLocationPage> {
appBar:
buildAppBar
(
title:
'选择定位地址'
,
onPressed:
(){
Map
<
String
,
dynamic
>
arguments
;
late
Map
<
String
,
dynamic
>
arguments
;
if
(
_currentLocationEntity
!=
null
){
arguments
=
{
'address'
:
_currentLocationEntity
?.
address
,
...
...
@@ -59,7 +60,7 @@ class _LifeLocationPageState extends State<LifeLocationPage> {
}
NavigateUtils
.
pop
(
arguments:
arguments
);
}
),
)
as
PreferredSizeWidget
?
,
body:
_buildBody
(),
);
}
...
...
@@ -68,16 +69,16 @@ class _LifeLocationPageState extends State<LifeLocationPage> {
return
Column
(
children:
[
buildSearchWidget
(
enabled:
!(
_currentCity
==
null
||
_currentCity
.
isEmpty
),
enabled:
!(
_currentCity
==
null
||
_currentCity
!
.
isEmpty
),
city:
_currentCity
??
'加载中...'
,
hintText:
(
_currentCity
==
null
||
_currentCity
.
isEmpty
)
hintText:
(
_currentCity
==
null
||
_currentCity
!
.
isEmpty
)
?
'请输入城市名称'
:
'在
$_currentCity
内搜索'
,
onCityTap:
()
{
pushCity
();
},
onEnterCity:
()
{
if
(
_currentCity
==
null
||
_currentCity
.
isEmpty
)
{
if
(
_currentCity
==
null
||
_currentCity
!
.
isEmpty
)
{
pushCity
();
}
},
...
...
@@ -86,7 +87,7 @@ class _LifeLocationPageState extends State<LifeLocationPage> {
},
),
Expanded
(
child:
(
_searchTips
==
null
||
_searchTips
.
isEmpty
)
child:
(
_searchTips
==
null
||
_searchTips
!
.
isEmpty
)
?
CustomScrollView
(
slivers:
[
//获取当前定位按钮
...
...
@@ -147,10 +148,10 @@ class _LifeLocationPageState extends State<LifeLocationPage> {
],
)
:
ListView
.
builder
(
itemCount:
_searchTips
.
length
,
itemCount:
_searchTips
!
.
length
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
MapTipEntity
entity
=
_searchTips
[
index
];
List
<
TextSpan
>
childs
=
entity
.
name
.
split
(
""
).
map
((
s
)
{
MapTipEntity
entity
=
_searchTips
!
[
index
];
List
<
TextSpan
>
childs
=
entity
.
name
!
.
split
(
""
).
map
((
s
)
{
bool
isKeyWordChar
=
this
.
searchKeywords
.
indexOf
(
s
)
>
-
1
;
return
TextSpan
(
text:
s
,
...
...
@@ -207,17 +208,17 @@ class _LifeLocationPageState extends State<LifeLocationPage> {
);
}
void
popAddress
({
Map
<
String
,
dynamic
>
arguments
})
{
void
popAddress
({
required
Map
<
String
,
dynamic
>
arguments
})
{
NavigateUtils
.
pop
(
arguments:
arguments
).
then
(
(
value
)
{
_historyLocations
.
removeWhere
(
_historyLocations
!
.
removeWhere
(
(
item
)
=>
item
[
'name'
]
==
arguments
[
'name'
],
);
_historyLocations
.
insert
(
0
,
arguments
);
if
(
_historyLocations
.
length
>
5
)
{
_historyLocations
.
removeAt
(
5
);
_historyLocations
!
.
insert
(
0
,
arguments
);
if
(
_historyLocations
!
.
length
>
5
)
{
_historyLocations
!
.
removeAt
(
5
);
}
StoreUtils
.
getInstance
().
setKV
(
StoreUtils
.
getInstance
()
!
.
setKV
(
key:
Res
.
historyLocation
,
value:
_historyLocations
,
);
...
...
@@ -227,7 +228,7 @@ class _LifeLocationPageState extends State<LifeLocationPage> {
String
searchKeywords
=
''
;
void
searchForKeywordsTips
({
String
keywords
})
async
{
void
searchForKeywordsTips
({
required
String
keywords
})
async
{
AMapRepository
.
get
()
.
inputSearchTips
(
key:
Res
.
aWebMapKey
,
...
...
@@ -252,7 +253,7 @@ class _LifeLocationPageState extends State<LifeLocationPage> {
void
pushCity
()
{
Map
<
String
,
dynamic
>
arguments
=
{};
if
(
_mCurrentCity
!=
null
&&
_mCurrentCity
.
isNotEmpty
)
{
if
(
_mCurrentCity
!=
null
&&
_mCurrentCity
!
.
isNotEmpty
)
{
arguments
[
'currentCity'
]
=
_mCurrentCity
;
}
NavigateUtils
.
push
(
...
...
@@ -260,7 +261,7 @@ class _LifeLocationPageState extends State<LifeLocationPage> {
arguments:
arguments
,
).
then
((
value
)
{
if
(
value
is
Map
&&
value
[
'city'
]
!=
null
)
{
String
_city
=
value
[
'city'
];
String
?
_city
=
value
[
'city'
];
setState
(()
{
_currentCity
=
_city
;
});
...
...
@@ -281,12 +282,12 @@ class _LifeLocationPageState extends State<LifeLocationPage> {
/// 如果有定位权限则读取定位权限
/// 否则使用网络定位显示城市
///
bool
enable
=
await
AmapsLocation
.
create
()
.
isOpenGPS
();
bool
has
=
await
LocationPermissionUtils
.
getInstance
().
hasPermission
();
if
(
has
&&
enable
)
{
bool
?
enable
=
await
AmapsLocation
.
create
()!
.
isOpenGPS
();
bool
has
=
await
LocationPermissionUtils
.
getInstance
()
!
.
hasPermission
();
if
(
has
&&
enable
!
)
{
//有定位权限
var
loading
=
LoadingDialogUtils
.
getInstance
().
show
();
AmapsLocation
.
create
()
var
loading
=
LoadingDialogUtils
.
getInstance
()
!
.
show
();
AmapsLocation
.
create
()
!
.
getLocation
(
apiKey:
Platform
.
isIOS
?
Res
.
aIOSMapKey
:
Res
.
aAndroidMapKey
)
.
then
(
...
...
@@ -328,16 +329,16 @@ class _LifeLocationPageState extends State<LifeLocationPage> {
if
(
isInit
)
{
ipConfigAddress
();
}
else
{
if
(
enable
)
{
if
(
enable
!
)
{
//有GPS
bool
confirm
=
await
Modal
.
showModal
(
bool
confirm
=
await
(
Modal
.
showModal
(
title:
"温馨提示"
,
msg:
"为给您提供更好的服务,需获取您的位置权限"
,
cancelBtnText:
'拒绝'
,
confirmBtnText:
'同意'
);
confirmBtnText:
'同意'
)
as
FutureOr
<
bool
>)
;
if
(
confirm
)
{
bool
has
=
await
LocationPermissionUtils
.
getInstance
().
reqPermission
();
await
LocationPermissionUtils
.
getInstance
()
!
.
reqPermission
();
if
(
has
)
{
startLocation
(
isInit:
false
,
isCurrent:
isCurrent
);
}
...
...
@@ -346,13 +347,13 @@ class _LifeLocationPageState extends State<LifeLocationPage> {
}
}
else
{
//没有GPS
bool
confirm
=
await
Modal
.
showModal
(
bool
confirm
=
await
(
Modal
.
showModal
(
title:
"温馨提示"
,
msg:
"为给您提供更好的服务,需获取您的位置权限"
,
cancelBtnText:
'拒绝'
,
confirmBtnText:
'同意'
);
confirmBtnText:
'同意'
)
as
FutureOr
<
bool
>)
;
if
(
confirm
)
{
AmapsLocation
.
create
().
enableGPS
().
then
((
value
)
{});
AmapsLocation
.
create
()
!
.
enableGPS
().
then
((
value
)
{});
}
}
}
...
...
@@ -361,7 +362,7 @@ class _LifeLocationPageState extends State<LifeLocationPage> {
bool
startLocationLoading
=
false
;
void
queryNearbyInfo
({
@
required
String
location
})
{
void
queryNearbyInfo
({
required
String
location
})
{
setState
(()
{
startLocationLoading
=
true
;
});
...
...
@@ -411,8 +412,8 @@ class _LifeLocationPageState extends State<LifeLocationPage> {
///
void
getHistoryLocations
()
{
_historyLocations
=
StoreUtils
.
getInstance
().
getForKey
(
key:
Res
.
historyLocation
);
if
(
_historyLocations
==
null
||
_historyLocations
.
isEmpty
)
{
StoreUtils
.
getInstance
()
!
.
getForKey
(
key:
Res
.
historyLocation
);
if
(
_historyLocations
==
null
||
_historyLocations
!
.
isEmpty
)
{
_historyLocations
=
List
<
dynamic
>.
empty
(
growable:
true
);
}
}
...
...
lib/views/life/actions/action.dart
View file @
6d6dc3e5
...
...
@@ -22,7 +22,7 @@ class IAction extends BaseAction<Model> {
void
_init
()
async
{
setModel
(
Model
());
await
getModel
().
findPermission
();
await
getModel
()
!
.
findPermission
();
initLocation
();
await
getAppNavModel
().
getAppNavList
();
await
getMiniBannerModel
().
getActivityConfigList
();
...
...
@@ -30,23 +30,23 @@ class IAction extends BaseAction<Model> {
void
initLocation
()
async
{
// 没有定位权限,用ip定位
bool
isFirstLifeLocation
=
StoreUtils
.
getInstance
()
.
getForKey
(
key:
'is_first_life_location2'
);
bool
?
isFirstLifeLocation
=
StoreUtils
.
getInstance
()!
.
getForKey
(
key:
'is_first_life_location2'
);
if
(
isFirstLifeLocation
==
null
){
StoreUtils
.
getInstance
().
setKV
(
key:
'is_first_life_location2'
,
value:
true
);
await
getModel
().
reqPermission
();
StoreUtils
.
getInstance
()
!
.
setKV
(
key:
'is_first_life_location2'
,
value:
true
);
await
getModel
()
!
.
reqPermission
();
initLocation
();
}
else
if
(!
getModel
()
.
getHasPermission
()
)
{
getModel
().
ipConfigAddress
().
then
((
value
)
=>
initData
());
}
else
if
(!
getModel
()
!.
getHasPermission
()!
)
{
getModel
()
!
.
ipConfigAddress
().
then
((
value
)
=>
initData
());
}
else
{
getModel
().
getLocation
().
then
((
value
){
getModel
()
!
.
getLocation
().
then
((
value
){
initData
();
});
}
}
Future
<
void
>
initData
()
async
{
await
getModel
().
findCityId
();
String
cityId
=
getModel
()
.
getCityId
();
await
getModel
()
!
.
findCityId
();
String
?
cityId
=
getModel
()!
.
getCityId
();
print
(
'===========> cityId:
$cityId
'
);
if
(
cityId
!=
null
&&
cityId
.
isNotEmpty
)
{
await
getSecKillModel
().
findDisplay
(
cityId
);
...
...
@@ -56,7 +56,7 @@ class IAction extends BaseAction<Model> {
}
Future
<
void
>
refreshShopList
()
async
{
var
loading
=
LoadingDialogUtils
.
getInstance
().
show
();
var
loading
=
LoadingDialogUtils
.
getInstance
()
!
.
show
();
Future
.
delayed
(
Duration
(
seconds:
2
)).
then
((
value
)
{
if
(
loading
!=
null
)
{
loading
.
close
();
...
...
@@ -65,22 +65,22 @@ class IAction extends BaseAction<Model> {
try
{
getShopListModel
()
.
setShopTypeNavIndex
(
getFilterModel
().
getShopTypeNavIndex
());
getShopListModel
().
setCityId
(
getModel
().
getCityId
());
getShopListModel
().
setLat
(
getModel
().
getLatitude
());
getShopListModel
().
setLng
(
getModel
().
getLongitude
());
getShopListModel
().
setCityId
(
getModel
()
!
.
getCityId
());
getShopListModel
().
setLat
(
getModel
()
!
.
getLatitude
());
getShopListModel
().
setLng
(
getModel
()
!
.
getLongitude
());
getShopListModel
()
.
setFirstCateId
(
getFilterModel
().
getCheckedOneCategory
().
id
);
.
setFirstCateId
(
getFilterModel
().
getCheckedOneCategory
()
!
.
id
);
getShopListModel
()
.
setSecondCateId
(
getFilterModel
().
getCheckedTwoCategory
().
id
??
""
);
if
(
getFilterModel
().
getCheckedTwoRegion
().
id
==
null
)
{
.
setSecondCateId
(
getFilterModel
().
getCheckedTwoCategory
()
!
.
id
??
""
);
if
(
getFilterModel
().
getCheckedTwoRegion
()
!
.
id
==
null
)
{
getShopListModel
()
.
setRegionId
(
getFilterModel
().
getCheckedOneRegion
().
id
);
.
setRegionId
(
getFilterModel
().
getCheckedOneRegion
()
!
.
id
);
}
else
{
getShopListModel
()
.
setRegionId
(
getFilterModel
().
getCheckedTwoRegion
().
id
);
.
setRegionId
(
getFilterModel
().
getCheckedTwoRegion
()
!
.
id
);
}
getShopListModel
().
setSortType
(
getFilterModel
().
getCheckedOneSort
().
id
);
getShopListModel
().
setSortType
(
getFilterModel
().
getCheckedOneSort
()
!
.
id
);
getShopListModel
().
clear
();
getShopListModel
().
scrollTop
();
await
getShopListModel
().
refresh
();
...
...
@@ -91,7 +91,7 @@ class IAction extends BaseAction<Model> {
}
void
refresh
()
async
{
String
cityId
=
getModel
()
.
getCityId
();
String
?
cityId
=
getModel
()!
.
getCityId
();
try
{
await
getAppNavModel
().
getAppNavList
();
await
getMiniBannerModel
().
getActivityConfigList
();
...
...
lib/views/life/components/diamond_bit.dart
View file @
6d6dc3e5
...
...
@@ -9,16 +9,16 @@ import 'package:life_module/utils/activity_config_tap_utils.dart';
/// 钻石位
class
DiamondBit
extends
StatelessWidget
{
final
IAction
iAction
;
final
IAction
?
iAction
;
final
ValueNotifier
<
double
>
scrollIndex
=
ValueNotifier
(
0.0
);
DiamondBit
({
Key
key
,
this
.
iAction
})
:
super
(
key:
key
);
DiamondBit
({
Key
?
key
,
this
.
iAction
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
SliverToBoxAdapter
(
child:
QMProvider
<
AppNavModel
>.
value
(
model:
iAction
.
getAppNavModel
(),
model:
iAction
!
.
getAppNavModel
(),
builderWidget:
(
context
,
model
,
child
)
{
if
(
model
.
getList
().
length
==
0
)
{
return
SizedBox
();
...
...
@@ -40,7 +40,7 @@ class DiamondBit extends StatelessWidget {
ValueListenableBuilder
<
double
>(
valueListenable:
scrollIndex
,
builder:
(
BuildContext
context
,
dynamic
value
,
Widget
child
)
{
(
BuildContext
context
,
dynamic
value
,
Widget
?
child
)
{
return
_DiamondBitWidgetPagination
(
offset:
value
,
itemCount:
model
.
getList
().
length
);
},
...
...
@@ -79,7 +79,7 @@ class _DiamondGrid extends StatelessWidget {
var
item
=
items
[
index
];
return
InkWell
(
onTap:
()
{
AppTapConfigUtils
.
getInstance
().
activityConfigTap
(
item
.
toJson
());
AppTapConfigUtils
.
getInstance
()
!
.
activityConfigTap
(
item
.
toJson
());
},
child:
Container
(
alignment:
Alignment
.
topCenter
,
...
...
@@ -92,7 +92,7 @@ class _DiamondGrid extends StatelessWidget {
width:
40
.
rpx
,
height:
40
.
rpx
,
child:
XiaoxiongBaseImageWidget
(
imageUrl:
item
.
iconUrl
,
imageUrl:
item
.
iconUrl
!
,
width:
40
.
rpx
,
height:
40
.
rpx
,
fit:
BoxFit
.
cover
,
...
...
@@ -102,7 +102,7 @@ class _DiamondGrid extends StatelessWidget {
height:
2
.
rpx
,
),
Text
(
item
.
name
,
item
.
name
!
,
overflow:
TextOverflow
.
ellipsis
,
style:
TextStyle
(
height:
1.3846153846153
,
...
...
@@ -123,15 +123,15 @@ class _DiamondGrid extends StatelessWidget {
/// 指示器
class
_DiamondBitWidgetPagination
extends
StatelessWidget
{
final
double
offset
;
final
int
itemCount
;
final
double
?
offset
;
final
int
?
itemCount
;
_DiamondBitWidgetPagination
({
Key
key
,
this
.
offset
,
this
.
itemCount
})
_DiamondBitWidgetPagination
({
Key
?
key
,
this
.
offset
,
this
.
itemCount
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
if
(
itemCount
==
10
||
itemCount
<=
5
)
{
if
(
itemCount
==
10
||
itemCount
!
<=
5
)
{
return
SizedBox
();
}
return
Container
(
...
...
lib/views/life/components/float_banner.dart
View file @
6d6dc3e5
...
...
@@ -7,12 +7,12 @@ import 'package:life_module/utils/activity_config_tap_utils.dart';
// assets/close_btn_black.png
class
FloatBanner
extends
StatelessWidget
{
final
MiniBannerModel
model
;
final
MiniBannerModel
?
model
;
FloatBanner
({
this
.
model
});
@override
Widget
build
(
BuildContext
context
)
{
return
QMProvider
<
MiniBannerModel
>.
value
(
model:
model
,
model:
model
!
,
builderWidget:
(
context
,
model
,
child
)
{
if
(
model
.
getFloatBannerEntity
()
==
null
)
{
return
SizedBox
();
...
...
@@ -28,7 +28,7 @@ class FloatBanner extends StatelessWidget {
top:
10
.
rpx
,
child:
InkWell
(
onTap:
()
{
AppTapConfigUtils
.
getInstance
()
.
activityConfigTap
(
model
.
getFloatBannerEntity
()
.
toJson
());
AppTapConfigUtils
.
getInstance
()
!.
activityConfigTap
(
model
.
getFloatBannerEntity
()!
.
toJson
());
model
.
removeFloatBannerEntity
(
true
);
},
child:
Container
(
...
...
@@ -37,7 +37,7 @@ class FloatBanner extends StatelessWidget {
//padding: EdgeInsets.symmetric(horizontal: 9.rpx),
margin:
EdgeInsets
.
only
(
top:
6
.
rpx
,
bottom:
6
.
rpx
),
child:
XiaoxiongBaseImageWidget
(
imageUrl:
model
.
getFloatBannerEntity
()
.
imgUrl
,
imageUrl:
model
.
getFloatBannerEntity
()
!.
imgUrl
!
,
height:
76
.
rpx
,
fit:
BoxFit
.
contain
,
placeholder:
(
BuildContext
context
,
String
data
){
...
...
lib/views/life/components/mini_banner.dart
View file @
6d6dc3e5
...
...
@@ -6,13 +6,13 @@ import 'package:common_module/widget/xiaoxiong_base_image_widget/widget.dart';
import
'package:life_module/utils/activity_config_tap_utils.dart'
;
class
MiniBanner
extends
StatelessWidget
{
final
MiniBannerModel
model
;
final
MiniBannerModel
?
model
;
MiniBanner
({
this
.
model
});
@override
Widget
build
(
BuildContext
context
)
{
return
SliverToBoxAdapter
(
child:
QMProvider
<
MiniBannerModel
>.
value
(
model:
model
,
model:
model
!
,
builderWidget:
(
context
,
model
,
child
)
{
if
(
model
.
getList
().
length
==
0
)
{
return
SizedBox
();
...
...
@@ -22,7 +22,7 @@ class MiniBanner extends StatelessWidget {
return
Expanded
(
child:
InkWell
(
onTap:
()
{
AppTapConfigUtils
.
getInstance
().
activityConfigTap
(
e
.
toJson
());
AppTapConfigUtils
.
getInstance
()
!
.
activityConfigTap
(
e
.
toJson
());
},
child:
Container
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
4
.
rpx
),
...
...
@@ -31,7 +31,7 @@ class MiniBanner extends StatelessWidget {
child:
Container
(
height:
50
.
rpx
,
child:
XiaoxiongBaseImageWidget
(
imageUrl:
e
.
imgUrl
,
imageUrl:
e
.
imgUrl
!
,
height:
50
.
rpx
,
fit:
BoxFit
.
cover
,
),
...
...
lib/views/life/components/scroll_body.dart
View file @
6d6dc3e5
...
...
@@ -15,21 +15,21 @@ import 'package:common_module/utils/navigate_utils.dart';
import
'package:life_module/route/index.dart'
;
class
ScrollBody
extends
StatefulWidget
{
final
IAction
iAction
;
final
String
isAuditMode
;
final
Function
(
double
offset
)
onScroll
;
final
ScrollController
controller
;
final
IAction
?
iAction
;
final
String
?
isAuditMode
;
final
Function
(
double
offset
)
?
onScroll
;
final
ScrollController
?
controller
;
ScrollBody
({
this
.
onScroll
,
this
.
iAction
,
this
.
controller
,
this
.
isAuditMode
});
@override
State
<
StatefulWidget
>
createState
()
=>
_ScrollBodyState
();
}
class
_ScrollBodyState
extends
State
<
ScrollBody
>
{
ScrollController
get
controller
=>
widget
.
controller
;
ScrollController
?
get
controller
=>
widget
.
controller
;
void
initState
()
{
super
.
initState
();
controller
.
addListener
(()
{
widget
.
onScroll
(
controller
.
offset
);
controller
!
.
addListener
(()
{
widget
.
onScroll
!(
controller
!
.
offset
);
});
}
...
...
@@ -37,12 +37,12 @@ class _ScrollBodyState extends State<ScrollBody> {
Widget
build
(
BuildContext
context
)
{
return
PullWidget
(
headerInsertIndex:
1
,
controller:
widget
.
iAction
.
getShopListModel
().
getRefreshController
(),
controller:
widget
.
iAction
!
.
getShopListModel
().
getRefreshController
(),
onLoad:
()
{
widget
.
iAction
.
getShopListModel
().
getData
();
widget
.
iAction
!
.
getShopListModel
().
getData
();
},
onRefresh:
()
{
widget
.
iAction
.
getShopListModel
().
refresh
();
widget
.
iAction
!
.
getShopListModel
().
refresh
();
},
child:
CustomScrollView
(
controller:
controller
,
...
...
@@ -58,7 +58,7 @@ class _ScrollBodyState extends State<ScrollBody> {
iAction:
widget
.
iAction
,
),
MiniBanner
(
model:
widget
.
iAction
.
getMiniBannerModel
(),
model:
widget
.
iAction
!
.
getMiniBannerModel
(),
),
SliverPersistentHeader
(
pinned:
false
,
...
...
@@ -66,9 +66,9 @@ class _ScrollBodyState extends State<ScrollBody> {
minHeight:
37
.
rpx
,
maxHeight:
37
.
rpx
,
child:
ShopTypeNav
(
model:
widget
.
iAction
.
getFilterModel
(),
model:
widget
.
iAction
!
.
getFilterModel
(),
onChange:
()
{
widget
.
iAction
.
refreshShopList
();
widget
.
iAction
!
.
refreshShopList
();
},
))),
SliverPersistentHeader
(
...
...
@@ -78,11 +78,11 @@ class _ScrollBodyState extends State<ScrollBody> {
maxHeight:
48
.
rpx
,
child:
FilterArea
(
topOffset:
81
.
rpx
-
37
.
rpx
,
model:
widget
.
iAction
.
getFilterModel
(),
model:
widget
.
iAction
!
.
getFilterModel
(),
onTap:
(
c
)
{
var
_context
=
widget
.
iAction
.
getShopListModel
().
getContext
()
;
RenderSliver
renderSliver
=
_context
widget
.
iAction
!.
getShopListModel
().
getContext
()!
;
RenderSliver
?
renderSliver
=
_context
.
findAncestorRenderObjectOfType
<
RenderSliver
>();
if
(
renderSliver
!=
null
&&
renderSliver
.
constraints
.
overlap
<=
0
)
{
...
...
@@ -90,7 +90,7 @@ class _ScrollBodyState extends State<ScrollBody> {
}
},
onChange:
()
{
widget
.
iAction
.
refreshShopList
();
widget
.
iAction
!
.
refreshShopList
();
},
))),
SliverPersistentHeader
(
...
...
@@ -99,17 +99,17 @@ class _ScrollBodyState extends State<ScrollBody> {
minHeight:
40
.
rpx
,
maxHeight:
40
.
rpx
,
child:
ShopClassNav
(
model:
widget
.
iAction
.
getFilterModel
(),
model:
widget
.
iAction
!
.
getFilterModel
(),
onChange:
()
{
widget
.
iAction
.
refreshShopList
();
widget
.
iAction
!
.
refreshShopList
();
},
))),
ShopList
(
model:
widget
.
iAction
.
getShopListModel
(),
model:
widget
.
iAction
!
.
getShopListModel
(),
onReset:
()
{
widget
.
iAction
.
getFilterModel
().
reset
();
widget
.
iAction
.
refreshShopList
();
widget
.
iAction
!
.
getFilterModel
().
reset
();
widget
.
iAction
!
.
refreshShopList
();
},
onTap:
(
item
)
{
NavigateUtils
.
push
(
...
...
@@ -117,16 +117,16 @@ class _ScrollBodyState extends State<ScrollBody> {
arguments:
{
'isAuditMode'
:
widget
.
isAuditMode
,
'shopId'
:
item
.
combo
!=
null
?
item
.
combo
.
shopId
:
item
.
restaurant
.
shopId
,
'lat'
:
widget
.
iAction
.
getModel
()
.
getLatitude
(),
'lng'
:
widget
.
iAction
.
getModel
()
.
getLongitude
(),
'firstCateId'
:
widget
.
iAction
?
item
.
combo
!
.
shopId
:
item
.
restaurant
!
.
shopId
,
'lat'
:
widget
.
iAction
!.
getModel
()!
.
getLatitude
(),
'lng'
:
widget
.
iAction
!.
getModel
()!
.
getLongitude
(),
'firstCateId'
:
widget
.
iAction
!
.
getFilterModel
()
.
getCheckedOneCategory
()
.
getCheckedOneCategory
()
!
.
id
,
'itemId'
:
item
.
combo
!=
null
?
item
.
combo
.
dealId
:
""
,
"cityName"
:
widget
.
iAction
.
getModel
()
.
getCity
()
'itemId'
:
item
.
combo
!=
null
?
item
.
combo
!
.
dealId
:
""
,
"cityName"
:
widget
.
iAction
!.
getModel
()!
.
getCity
()
},
isNative:
false
,
);
...
...
lib/views/life/components/search_area.dart
View file @
6d6dc3e5
...
...
@@ -11,8 +11,8 @@ import '../actions/action.dart';
import
'package:common_module/utils/map_utils.dart'
;
class
SearchArea
extends
StatefulWidget
{
final
IAction
iAction
;
final
ValueNotifier
<
double
>
scrollOffset
;
final
IAction
?
iAction
;
final
ValueNotifier
<
double
>
?
scrollOffset
;
SearchArea
({
this
.
scrollOffset
,
this
.
iAction
});
@override
State
<
StatefulWidget
>
createState
()
=>
_SearchAreaState
();
...
...
@@ -28,11 +28,11 @@ class _SearchAreaState extends State<SearchArea> {
return
Container
(
child:
QMProvider
<
Model
>.
value
(
model:
widget
.
iAction
.
getModel
()
,
model:
widget
.
iAction
!.
getModel
()!
,
builderWidget:
(
context
,
model
,
child
)
{
return
ValueListenableBuilder
<
double
>(
valueListenable:
widget
.
scrollOffset
,
builder:
(
BuildContext
context
,
dynamic
offset
,
Widget
child
)
{
valueListenable:
widget
.
scrollOffset
!
,
builder:
(
BuildContext
context
,
dynamic
offset
,
Widget
?
child
)
{
double
opacity
=
1
;
if
(
offset
>=
maxOffset
)
{
...
...
@@ -41,7 +41,7 @@ class _SearchAreaState extends State<SearchArea> {
offset
=
maxOffset
;
}
else
if
(
offset
>
0
)
{
// 滚动范围>0
opacity
=
1
-
offset
/
maxOffset
;
opacity
=
1
-
offset
/
maxOffset
as
double
;
}
else
if
(
offset
<
0
)
{
// 滚动范围小于0
offset
=
0.0
;
...
...
@@ -73,12 +73,12 @@ class _SearchAreaState extends State<SearchArea> {
NavigateUtils
.
push
(
path:
RouteCityPath
.
LIFE_SEARCH_PAGE
.
path
(),
arguments:
{
'cityId'
:
widget
.
iAction
.
getModel
()
.
getCityId
(),
'cityId'
:
widget
.
iAction
!.
getModel
()!
.
getCityId
(),
'latitude'
:
widget
.
iAction
.
getModel
()
.
getLatitude
(),
widget
.
iAction
!.
getModel
()!
.
getLatitude
(),
'longitude'
:
widget
.
iAction
.
getModel
()
.
getLongitude
(),
'cityName'
:
widget
.
iAction
.
getModel
()
.
getCity
(),
widget
.
iAction
!.
getModel
()!
.
getLongitude
(),
'cityName'
:
widget
.
iAction
!.
getModel
()!
.
getCity
(),
},
isNative:
false
,
);
...
...
@@ -92,7 +92,7 @@ class _SearchAreaState extends State<SearchArea> {
),
];
if
(!
model
.
getHasPermission
())
{
if
(!
model
.
getHasPermission
()
!
)
{
items
.
add
(
Positioned
(
top:
37
.
rpx
,
right:
13
.
rpx
,
...
...
@@ -118,12 +118,12 @@ class _SearchAreaState extends State<SearchArea> {
/// 定位按钮
class
_Locaion
extends
StatelessWidget
{
final
IAction
iAction
;
final
IAction
?
iAction
;
_Locaion
({
this
.
iAction
});
@override
Widget
build
(
BuildContext
context
)
{
return
QMProvider
<
Model
>.
value
(
model:
iAction
.
getModel
()
,
model:
iAction
!.
getModel
()!
,
builderWidget:
(
context
,
model
,
child
)
{
return
InkWell
(
child:
Container
(
...
...
@@ -181,14 +181,14 @@ class _Locaion extends StatelessWidget {
var
location
=
result
[
'location'
].
split
(
','
);
var
_latitude
=
'
${location[1]}
'
;
var
_longitude
=
'
${location[0]}
'
;
List
<
num
>
arr
=
MapUtils
.
getInstance
().
gcj02ToGps84
(
List
<
num
>
arr
=
MapUtils
.
getInstance
()
!
.
gcj02ToGps84
(
double
.
parse
(
_latitude
),
double
.
parse
(
_longitude
));
_latitude
=
'
${arr[0]}
'
;
_longitude
=
'
${arr[1]}
'
;
model
.
setLocationInfo
(
result
[
'cityname'
]
??
result
[
'city'
],
result
[
'name'
],
_latitude
,
_longitude
);
await
iAction
.
initData
();
iAction
.
getModel
()
.
findPermission
();
await
iAction
!
.
initData
();
iAction
!.
getModel
()!
.
findPermission
();
},
);
});
...
...
@@ -197,7 +197,7 @@ class _Locaion extends StatelessWidget {
/// 气泡
class
_Bubble
extends
StatelessWidget
{
final
IAction
iAction
;
final
IAction
?
iAction
;
_Bubble
(
this
.
iAction
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -230,9 +230,9 @@ class _Bubble extends StatelessWidget {
children:
[
InkWell
(
onTap:
()
async
{
await
iAction
.
getModel
()
.
reqPermission
();
if
(
iAction
.
getModel
().
getHasPermission
()
)
{
iAction
.
initLocation
();
await
iAction
!.
getModel
()!
.
reqPermission
();
if
(
iAction
!.
getModel
()!.
getHasPermission
()!
)
{
iAction
!
.
initLocation
();
}
},
child:
Container
(
...
...
@@ -260,7 +260,7 @@ class _Bubble extends StatelessWidget {
),
),
onTap:
()
{
iAction
.
getModel
()
.
setPermission
();
iAction
!.
getModel
()!
.
setPermission
();
},
)
],
...
...
lib/views/life/components/sec_kill.dart
View file @
6d6dc3e5
...
...
@@ -19,7 +19,7 @@ const HOUR = 60 * MINUTE;
const
DAY
=
24
*
HOUR
;
class
SecKill
extends
StatefulWidget
{
final
IAction
iAction
;
final
IAction
?
iAction
;
SecKill
({
this
.
iAction
});
@override
State
<
StatefulWidget
>
createState
()
=>
_SecKillState
();
...
...
@@ -31,7 +31,7 @@ class _SecKillState extends State<SecKill> {
Widget
build
(
BuildContext
context
)
{
return
SliverToBoxAdapter
(
child:
QMProvider
<
SecKillModel
>.
value
(
model:
widget
.
iAction
.
getSecKillModel
(),
model:
widget
.
iAction
!
.
getSecKillModel
(),
builderWidget:
(
context
,
model
,
child
)
{
if
(!
model
.
isShow
()
&&
model
.
getSeckillSessionList
().
length
==
0
)
{
return
SizedBox
();
...
...
@@ -44,10 +44,10 @@ class _SecKillState extends State<SecKill> {
arguments:
{
'tid'
:
''
,
'times'
:
model
.
getSeckillSessionList
(),
"cityId"
:
widget
.
iAction
.
getModel
()
.
getCityId
(),
"lat"
:
widget
.
iAction
.
getModel
()
.
getLatitude
(),
"lng"
:
widget
.
iAction
.
getModel
()
.
getLongitude
(),
"cityName"
:
widget
.
iAction
.
getModel
()
.
getCity
()
"cityId"
:
widget
.
iAction
!.
getModel
()!
.
getCityId
(),
"lat"
:
widget
.
iAction
!.
getModel
()!
.
getLatitude
(),
"lng"
:
widget
.
iAction
!.
getModel
()!
.
getLongitude
(),
"cityName"
:
widget
.
iAction
!.
getModel
()!
.
getCity
()
},
isNative:
false
,
);
...
...
@@ -65,17 +65,17 @@ class _SecKillState extends State<SecKill> {
key:
ValueKey
(
model
.
getSeckillSessionList
()
.
map
((
e
)
=>
e
.
id
)
.
join
(
"_
${widget.iAction
.getModel().getLatitude()}
_
${widget.iAction.getModel()
.getLongitude()}
"
)),
.
join
(
"_
${widget.iAction
!.getModel()!.getLatitude()}
_
${widget.iAction!.getModel()!
.getLongitude()}
"
)),
seckillSessions:
model
.
getSeckillSessionList
(),
onNext:
(
seckillSession
)
async
{
await
widget
.
iAction
.
getModel
()
.
findCityId
();
print
(
'==============>_cityId:
${widget.iAction
.getModel()
.getCityId()}
'
);
await
widget
.
iAction
!.
getModel
()!
.
findCityId
();
print
(
'==============>_cityId:
${widget.iAction
!.getModel()!
.getCityId()}
'
);
scrollIndex
.
value
=
0
;
model
.
loadSecKillGoodsByShowId
(
widget
.
iAction
.
getModel
().
getCityId
()
,
seckillSession
.
id
,
widget
.
iAction
.
getModel
()
.
getLatitude
(),
widget
.
iAction
.
getModel
()
.
getLongitude
());
widget
.
iAction
!.
getModel
()!.
getCityId
()!
,
seckillSession
!.
id
!
,
widget
.
iAction
!.
getModel
()!
.
getLatitude
(),
widget
.
iAction
!.
getModel
()!
.
getLongitude
());
},
),
_SecKillGoodsBody
(
...
...
@@ -101,22 +101,22 @@ class _SecKillState extends State<SecKill> {
/// 秒杀标题
class
_SecKillTitle
extends
StatefulWidget
{
final
List
<
SeckillSession
>
seckillSessions
;
final
Function
(
SeckillSession
session
)
onNext
;
_SecKillTitle
({
this
.
seckillSessions
,
this
.
onNext
,
Key
key
})
:
super
(
key:
key
);
final
List
<
SeckillSession
?>?
seckillSessions
;
final
Function
(
SeckillSession
?
session
)?
onNext
;
_SecKillTitle
({
this
.
seckillSessions
,
this
.
onNext
,
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
StatefulWidget
>
createState
()
=>
_SecKillTitleState
();
}
class
_SecKillTitleState
extends
State
<
_SecKillTitle
>
{
List
<
SeckillSession
>
get
seckillSessions
=>
widget
.
seckillSessions
;
List
<
SeckillSession
?>?
get
seckillSessions
=>
widget
.
seckillSessions
;
String
statusText
=
''
;
int
startTime
;
int
endTime
;
int
?
startTime
;
int
?
endTime
;
bool
isStart
=
false
;
SeckillSession
seckillSession
;
SeckillSession
?
seckillSession
;
@override
void
initState
()
{
super
.
initState
();
...
...
@@ -124,7 +124,7 @@ class _SecKillTitleState extends State<_SecKillTitle> {
}
void
setStartAndEndTime
(
SeckillSession
session
)
{
var
timeArr
=
session
.
text
.
split
(
"-"
);
var
timeArr
=
session
.
text
!
.
split
(
"-"
);
String
nowDate
=
DateUtil
.
formatDate
(
DateTime
.
now
(),
format:
"yyyy-MM-dd"
);
startTime
=
DateUtil
.
getDateMsByTimeStr
(
"
$nowDate
${timeArr[0]}
"
);
endTime
=
DateUtil
.
getDateMsByTimeStr
(
"
$nowDate
${timeArr[1]}
"
);
...
...
@@ -132,14 +132,14 @@ class _SecKillTitleState extends State<_SecKillTitle> {
void
init
()
{
int
nowTime
=
DateTime
.
now
().
millisecondsSinceEpoch
;
seckillSession
=
seckillSessions
.
firstWhere
((
session
)
{
setStartAndEndTime
(
session
);
if
(
startTime
<=
nowTime
&&
endTime
>=
nowTime
)
{
seckillSession
=
seckillSessions
!
.
firstWhere
((
session
)
{
setStartAndEndTime
(
session
!
);
if
(
startTime
!
<=
nowTime
&&
endTime
!
>=
nowTime
)
{
isStart
=
true
;
return
true
;
}
if
(
startTime
>
nowTime
)
{
if
(
startTime
!
>
nowTime
)
{
isStart
=
false
;
return
true
;
}
...
...
@@ -150,35 +150,35 @@ class _SecKillTitleState extends State<_SecKillTitle> {
if
(
seckillSession
==
null
)
{
return
;
}
if
(
startTime
>
nowTime
)
{
if
(
startTime
!
>
nowTime
)
{
runStartTimeDown
();
}
else
if
(
startTime
<
nowTime
&&
endTime
>
nowTime
)
{
}
else
if
(
startTime
!
<
nowTime
&&
endTime
!
>
nowTime
)
{
runEndTimeDown
();
}
widget
.
onNext
(
seckillSession
);
widget
.
onNext
!
(
seckillSession
);
}
void
next
()
{
int
index
=
seckillSessions
.
indexOf
(
seckillSession
);
if
(
index
>=
seckillSessions
.
length
-
1
)
{
int
index
=
seckillSessions
!
.
indexOf
(
seckillSession
);
if
(
index
>=
seckillSessions
!
.
length
-
1
)
{
return
;
}
seckillSession
=
seckillSessions
[
index
+
1
];
setStartAndEndTime
(
seckillSession
);
seckillSession
=
seckillSessions
!
[
index
+
1
];
setStartAndEndTime
(
seckillSession
!
);
int
nowTime
=
DateTime
.
now
().
millisecondsSinceEpoch
;
if
(
startTime
>
nowTime
)
{
if
(
startTime
!
>
nowTime
)
{
isStart
=
false
;
runStartTimeDown
();
}
else
if
(
startTime
<
nowTime
&&
endTime
>
nowTime
)
{
}
else
if
(
startTime
!
<
nowTime
&&
endTime
!
>
nowTime
)
{
isStart
=
true
;
runEndTimeDown
();
}
widget
.
onNext
(
seckillSession
);
widget
.
onNext
!
(
seckillSession
);
}
void
runStartTimeDown
()
{
int
nowTime
=
DateTime
.
now
().
millisecondsSinceEpoch
;
int
dur
=
startTime
-
nowTime
;
int
dur
=
startTime
!
-
nowTime
;
int
h
=
((
dur
%
DAY
)
/
HOUR
).
floor
();
int
i
=
((
dur
%
HOUR
)
/
MINUTE
).
floor
();
int
s
=
((
dur
%
MINUTE
)
/
SECOND
).
floor
();
...
...
@@ -203,7 +203,7 @@ class _SecKillTitleState extends State<_SecKillTitle> {
void
runEndTimeDown
()
{
int
nowTime
=
DateTime
.
now
().
millisecondsSinceEpoch
;
int
dur
=
endTime
-
nowTime
;
int
dur
=
endTime
!
-
nowTime
;
int
h
=
((
dur
%
DAY
)
/
HOUR
).
floor
();
int
i
=
((
dur
%
HOUR
)
/
MINUTE
).
floor
();
int
s
=
((
dur
%
MINUTE
)
/
SECOND
).
floor
();
...
...
@@ -292,12 +292,12 @@ class _SecKillTitleState extends State<_SecKillTitle> {
}
class
_SecKillGoodsBody
extends
StatelessWidget
{
final
SecKillModel
model
;
final
Function
(
int
)
onChange
;
final
SecKillModel
?
model
;
final
Function
(
int
)
?
onChange
;
_SecKillGoodsBody
({
this
.
model
,
this
.
onChange
});
@override
Widget
build
(
BuildContext
context
)
{
List
<
SecKillGoods
>
list
=
model
.
getSecKillGoodsList
();
List
<
SecKillGoods
>
list
=
model
!
.
getSecKillGoodsList
();
if
(
list
.
length
==
0
)
{
return
Expanded
(
child:
Container
(
...
...
@@ -327,7 +327,7 @@ class _SecKillGoodsBody extends StatelessWidget {
onPageChanged:
onChange
,
children:
items
,
),
onNotification:
(
e
)
{
onNotification:
(
dynamic
e
)
{
return
true
;
},
),
...
...
@@ -337,7 +337,7 @@ class _SecKillGoodsBody extends StatelessWidget {
/// 单场秒杀
class
_SecKillItem
extends
StatefulWidget
{
final
List
<
SecKillGoods
>
list
;
final
List
<
SecKillGoods
>
?
list
;
_SecKillItem
({
this
.
list
});
@override
...
...
@@ -366,16 +366,16 @@ class _SecKillItemState extends State<_SecKillItem> {
/// 秒杀商品
class
_SecKillGoods
extends
StatelessWidget
{
final
List
<
SecKillGoods
>
list
;
final
List
<
SecKillGoods
>
?
list
;
_SecKillGoods
({
this
.
list
});
@override
Widget
build
(
BuildContext
context
)
{
int
len
=
list
.
length
-
1
;
int
len
=
list
!
.
length
-
1
;
List
<
Widget
>
childs
=
List
.
generate
(
2
,
(
index
)
{
if
(
index
>
len
)
{
return
Expanded
(
child:
SizedBox
());
}
return
_SecKillGoodsItem
(
list
[
index
]);
return
_SecKillGoodsItem
(
list
!
[
index
]);
}).
toList
();
return
Row
(
...
...
@@ -400,7 +400,7 @@ class _SecKillGoodsItem extends StatelessWidget {
height:
73
.
rpx
,
width:
73
.
rpx
,
child:
XiaoxiongBaseImageWidget
(
imageUrl:
item
.
itemPic
,
imageUrl:
item
.
itemPic
!
,
height:
73
.
rpx
,
width:
73
.
rpx
,
fit:
BoxFit
.
cover
,
...
...
@@ -416,7 +416,7 @@ class _SecKillGoodsItem extends StatelessWidget {
Container
(
height:
32
.
rpx
,
child:
Text
(
item
.
itemTitle
,
item
.
itemTitle
!
,
overflow:
TextOverflow
.
ellipsis
,
maxLines:
2
,
style:
TextStyle
(
...
...
@@ -436,7 +436,7 @@ class _SecKillGoodsItem extends StatelessWidget {
topRight:
Radius
.
circular
(
9
.
rpx
),
bottomRight:
Radius
.
circular
(
9
.
rpx
))),
child:
Text
(
item
.
userCommissionText
,
item
.
userCommissionText
!
,
style:
TextStyle
(
color:
rgba
(
255
,
128
,
0
,
1
),
fontSize:
11
.
rpx
,
...
...
@@ -457,7 +457,7 @@ class _SecKillGoodsItem extends StatelessWidget {
),
),
Text
(
item
.
endPrice
,
item
.
endPrice
!
,
style:
TextStyle
(
color:
rgba
(
255
,
4
,
0
,
1
),
fontSize:
14
.
rpx
,
...
...
@@ -488,23 +488,23 @@ class _SecKillGoodsItem extends StatelessWidget {
/// 指示器
class
_SecKillPagination
extends
StatelessWidget
{
final
SecKillModel
model
;
final
ValueNotifier
<
int
>
scrollIndex
;
final
SecKillModel
?
model
;
final
ValueNotifier
<
int
>
?
scrollIndex
;
_SecKillPagination
({
this
.
scrollIndex
,
this
.
model
});
@override
Widget
build
(
BuildContext
context
)
{
if
(
model
.
getSecKillGoodsList
().
length
==
0
)
{
if
(
model
!
.
getSecKillGoodsList
().
length
==
0
)
{
return
SizedBox
(
height:
4
.
rpx
,
);
}
return
ValueListenableBuilder
<
int
>(
valueListenable:
scrollIndex
,
builder:
(
BuildContext
context
,
dynamic
offset
,
Widget
child
)
{
valueListenable:
scrollIndex
!
,
builder:
(
BuildContext
context
,
dynamic
offset
,
Widget
?
child
)
{
List
<
Widget
>
items
=
List
.
generate
(
(
model
.
getSecKillGoodsList
().
length
/
2
).
ceil
(),
(
index
)
{
(
model
!
.
getSecKillGoodsList
().
length
/
2
).
ceil
(),
(
index
)
{
Color
color
=
rgba
(
216
,
216
,
216
,
1
);
if
(
index
==
scrollIndex
.
value
)
{
if
(
index
==
scrollIndex
!
.
value
)
{
color
=
rgba
(
255
,
128
,
0
,
1
);
}
return
Container
(
...
...
lib/views/life/models/mini_banner_model.dart
View file @
6d6dc3e5
...
...
@@ -7,7 +7,7 @@ const String _SHOP_KEY_ = "__life_float_banner__";
class
MiniBannerModel
extends
BaseModel
{
List
<
ActivityConfigEntity
>
_list
=
[];
ActivityConfigEntity
floatBanner
;
ActivityConfigEntity
?
floatBanner
;
Future
<
void
>
getActivityConfigList
()
async
{
_list
=
await
AppNavRepository
.
get
().
getActivityConfigList
(
"20"
);
...
...
@@ -23,12 +23,12 @@ class MiniBannerModel extends BaseModel {
return
_list
;
}
ActivityConfigEntity
getFloatBannerEntity
()
{
ActivityConfigEntity
?
getFloatBannerEntity
()
{
if
(
floatBanner
!=
null
)
{
String
type
=
floatBanner
.
showType
;
String
?
type
=
floatBanner
!
.
showType
;
if
(
type
!=
'2'
)
{
String
dateStr
=
StoreUtils
.
getInstance
()
.
getForKey
(
key:
"
$_SHOP_KEY_${floatBanner.id}
"
);
String
?
dateStr
=
StoreUtils
.
getInstance
()!
.
getForKey
(
key:
"
$_SHOP_KEY_${floatBanner
!
.id}
"
);
if
(
type
==
'1'
&&
dateStr
!=
null
)
{
return
null
;
}
...
...
@@ -46,8 +46,8 @@ class MiniBannerModel extends BaseModel {
if
(
floatBanner
!=
null
)
{
String
nowDateStr
=
DateUtil
.
formatDate
(
DateTime
.
now
(),
format:
"yyyyMMdd"
);
StoreUtils
.
getInstance
()
.
setKV
(
key:
"
$_SHOP_KEY_${floatBanner.id}
"
,
value:
nowDateStr
);
StoreUtils
.
getInstance
()
!
.
setKV
(
key:
"
$_SHOP_KEY_${floatBanner
!
.id}
"
,
value:
nowDateStr
);
if
(!
show
)
{
floatBanner
=
null
;
notifyListeners
();
...
...
lib/views/life/models/model.dart
View file @
6d6dc3e5
import
'dart:async'
;
import
'package:common_module/utils/map_utils.dart'
;
import
'package:mvp/mvp.dart'
;
import
'package:life_repository/life_repository.dart'
;
...
...
@@ -6,27 +8,27 @@ import 'package:common_module/utils/amap_utils.dart';
import
'package:modal/modal.dart'
;
class
Model
extends
BaseModel
{
bool
_hasPermission
=
false
;
String
_address
=
''
;
String
_city
=
''
;
String
_cityId
=
''
;
bool
?
_hasPermission
=
false
;
String
?
_address
=
''
;
String
?
_city
=
''
;
String
?
_cityId
=
''
;
String
_latitude
=
''
;
String
_longitude
=
''
;
bool
_isClickCitySelect
=
false
;
Future
<
void
>
findCityId
()
async
{
_cityId
=
await
CityRepository
.
get
().
getCityId
(
_city
);
_cityId
=
await
CityRepository
.
get
().
getCityId
(
_city
!
);
}
Future
<
void
>
getLocation
()
async
{
LocationEntity
location
=
await
AmapUtils
.
getInstance
().
getLocation
();
LocationEntity
location
=
await
AmapUtils
.
getInstance
()
!
.
getLocation
();
if
((
location
?.
address
??
''
).
isEmpty
){
String
myLocation
=
'
${location.longitude}
,
${location.latitude}
'
;
location
=
await
Res
.
convertLocation
(
entity:
location
,
location:
myLocation
);
}
_latitude
=
location
.
latitude
.
toString
();
_longitude
=
location
.
longitude
.
toString
();
List
<
num
>
arr
=
MapUtils
.
getInstance
()
List
<
num
>
arr
=
MapUtils
.
getInstance
()
!
.
gcj02ToGps84
(
double
.
parse
(
_latitude
),
double
.
parse
(
_longitude
));
_latitude
=
'
${arr[0]}
'
;
_longitude
=
'
${arr[1]}
'
;
...
...
@@ -38,11 +40,11 @@ class Model extends BaseModel {
Future
<
void
>
ipConfigAddress
()
async
{
var
res
=
await
AMapRepository
.
get
().
ipConfigAddress
(
key:
Res
.
aWebMapKey
);
List
<
String
>
rectangles
=
res
.
rectangle
.
split
(
new
RegExp
(
r";|,"
));
List
<
String
>
rectangles
=
res
.
rectangle
!
.
split
(
new
RegExp
(
r";|,"
));
if
(
rectangles
.
length
>
1
)
{
_latitude
=
rectangles
[
1
];
_longitude
=
rectangles
[
0
];
List
<
num
>
arr
=
MapUtils
.
getInstance
()
List
<
num
>
arr
=
MapUtils
.
getInstance
()
!
.
gcj02ToGps84
(
double
.
parse
(
_latitude
),
double
.
parse
(
_longitude
));
_latitude
=
'
${arr[0]}
'
;
_longitude
=
'
${arr[1]}
'
;
...
...
@@ -53,36 +55,36 @@ class Model extends BaseModel {
}
Future
<
void
>
findPermission
()
async
{
_hasPermission
=
await
AmapUtils
.
getInstance
().
hasPermission
();
if
(
_hasPermission
)
{
_hasPermission
=
await
AmapUtils
.
getInstance
().
isOpenGPS
;
_hasPermission
=
await
AmapUtils
.
getInstance
()
!
.
hasPermission
();
if
(
_hasPermission
!
)
{
_hasPermission
=
await
AmapUtils
.
getInstance
()
!
.
isOpenGPS
;
}
notifyListeners
();
}
Future
<
void
>
reqPermission
()
async
{
bool
confirm
=
await
Modal
.
showModal
(
bool
confirm
=
await
(
Modal
.
showModal
(
title:
"温馨提示"
,
msg:
"为给您提供更好的服务,需获取您的位置权限"
,
cancelBtnText:
'拒绝'
,
confirmBtnText:
'同意'
);
confirmBtnText:
'同意'
)
as
FutureOr
<
bool
>)
;
if
(!
confirm
)
{
return
;
}
_hasPermission
=
await
AmapUtils
.
getInstance
().
reqPermission
();
_hasPermission
=
await
AmapUtils
.
getInstance
()
!
.
reqPermission
();
if
(
_hasPermission
)
{
_hasPermission
=
await
AmapUtils
.
getInstance
().
isOpenGPS
;
if
(!
_hasPermission
)
{
confirm
=
await
Modal
.
showModal
(
if
(
_hasPermission
!
)
{
_hasPermission
=
await
AmapUtils
.
getInstance
()
!
.
isOpenGPS
;
if
(!
_hasPermission
!
)
{
confirm
=
await
(
Modal
.
showModal
(
title:
"温馨提示"
,
msg:
"为给您提供更好的服务,请打开GPS"
,
cancelBtnText:
'拒绝'
,
confirmBtnText:
'同意'
);
confirmBtnText:
'同意'
)
as
FutureOr
<
bool
>)
;
if
(!
confirm
)
{
return
;
}
_hasPermission
=
await
AmapUtils
.
getInstance
().
enableGPS
();
_hasPermission
=
await
AmapUtils
.
getInstance
()
!
.
enableGPS
();
}
}
notifyListeners
();
...
...
@@ -93,12 +95,12 @@ class Model extends BaseModel {
notifyListeners
();
}
bool
getHasPermission
()
{
bool
?
getHasPermission
()
{
return
_hasPermission
;
}
void
setLocationInfo
(
String
city
,
String
address
,
String
latitude
,
String
longitude
)
{
String
?
city
,
String
?
address
,
String
latitude
,
String
longitude
)
{
_city
=
city
;
_address
=
address
;
_latitude
=
latitude
;
...
...
@@ -114,11 +116,11 @@ class Model extends BaseModel {
this
.
_address
=
name
;
}
String
getCityId
()
{
String
?
getCityId
()
{
return
_cityId
;
}
String
getCity
()
{
String
?
getCity
()
{
return
_city
;
}
...
...
lib/views/life/view.dart
View file @
6d6dc3e5
...
...
@@ -11,7 +11,7 @@ import 'package:common_module/widget/scroll_top_fixed_widget/widget.dart';
class
LifeWidget
extends
StatefulWidget
{
final
String
isAuditMode
;
LifeWidget
({
Key
key
,
@
required
this
.
isAuditMode
})
:
super
(
key:
key
);
LifeWidget
({
Key
?
key
,
required
this
.
isAuditMode
})
:
super
(
key:
key
);
@override
State
<
StatefulWidget
>
createState
()
=>
_LifeState
();
}
...
...
@@ -94,7 +94,7 @@ class _LifeState extends BaseUmengPageViewItemState<LifeWidget>
child:
ValueListenableBuilder
<
bool
>(
valueListenable:
floatBannerNotifier
,
builder:
(
BuildContext
context
,
bool
isScrollTStop
,
Widget
child
)
{
Widget
?
child
)
{
return
AnimatedContainer
(
duration:
Duration
(
milliseconds:
100
),
transform:
Matrix4
.
translationValues
(
...
...
@@ -116,15 +116,15 @@ class _LifeState extends BaseUmengPageViewItemState<LifeWidget>
@override
void
onResume
()
async
{
super
.
onResume
();
if
(!
iAction
.
getModel
()
.
getHasPermission
()
&&
!
iAction
.
getModel
().
isClickCitySelect
())
{
await
iAction
.
getModel
().
findPermission
();
if
(
iAction
.
getModel
()
.
getHasPermission
()
)
{
if
(!
iAction
.
getModel
()
!.
getHasPermission
()!
&&
!
iAction
.
getModel
()
!
.
isClickCitySelect
())
{
await
iAction
.
getModel
()
!
.
findPermission
();
if
(
iAction
.
getModel
()
!.
getHasPermission
()!
)
{
iAction
.
initLocation
();
}
}
if
(
iAction
.
getModel
().
isClickCitySelect
())
{
iAction
.
getModel
().
setIsClickCitySelect
(
false
);
if
(
iAction
.
getModel
()
!
.
isClickCitySelect
())
{
iAction
.
getModel
()
!
.
setIsClickCitySelect
(
false
);
}
}
...
...
lib/views/search/actions/action.dart
View file @
6d6dc3e5
...
...
@@ -5,10 +5,10 @@ import 'package:life_module/models/shop_list_model.dart';
import
'package:common_module/utils/loading_dialog_utils.dart'
;
class
IAction
extends
BaseAction
<
Model
>
{
String
_cityId
=
''
;
String
_latitude
=
''
;
String
_longitude
=
''
;
String
_cityName
=
''
;
String
?
_cityId
=
''
;
String
?
_latitude
=
''
;
String
?
_longitude
=
''
;
String
?
_cityName
=
''
;
FilterModel
_filterModel
=
FilterModel
();
ShopListModel
_shopListModel
=
ShopListModel
();
...
...
@@ -22,13 +22,13 @@ class IAction extends BaseAction<Model> {
void
_init
()
async
{
setModel
(
Model
(
_cityId
,
_latitude
,
_longitude
,
_cityName
));
if
(
_cityId
!=
null
&&
_cityId
.
isNotEmpty
)
{
await
getFilterModel
().
getFilterList
(
_cityId
);
if
(
_cityId
!=
null
&&
_cityId
!
.
isNotEmpty
)
{
await
getFilterModel
().
getFilterList
(
_cityId
!
);
}
}
Future
<
void
>
refreshShopList
()
async
{
var
loading
=
LoadingDialogUtils
.
getInstance
().
show
();
var
loading
=
LoadingDialogUtils
.
getInstance
()
!
.
show
();
Future
.
delayed
(
Duration
(
seconds:
2
)).
then
((
value
)
{
if
(
loading
!=
null
)
{
loading
.
close
();
...
...
@@ -37,24 +37,24 @@ class IAction extends BaseAction<Model> {
try
{
getShopListModel
()
.
setShopTypeNavIndex
(
getFilterModel
().
getShopTypeNavIndex
());
getShopListModel
().
setCityId
(
getModel
().
getCityId
());
getShopListModel
().
setLat
(
getModel
().
getLatitude
());
getShopListModel
().
setLng
(
getModel
().
getLongitude
());
getShopListModel
().
setCityId
(
getModel
()
!
.
getCityId
());
getShopListModel
().
setLat
(
getModel
()
!
.
getLatitude
());
getShopListModel
().
setLng
(
getModel
()
!
.
getLongitude
());
getShopListModel
()
.
setFirstCateId
(
getFilterModel
().
getCheckedOneCategory
().
id
);
.
setFirstCateId
(
getFilterModel
().
getCheckedOneCategory
()
!
.
id
);
getShopListModel
()
.
setSecondCateId
(
getFilterModel
().
getCheckedTwoCategory
().
id
??
""
);
if
(
getFilterModel
().
getCheckedTwoRegion
().
id
==
null
)
{
.
setSecondCateId
(
getFilterModel
().
getCheckedTwoCategory
()
!
.
id
??
""
);
if
(
getFilterModel
().
getCheckedTwoRegion
()
!
.
id
==
null
)
{
getShopListModel
()
.
setRegionId
(
getFilterModel
().
getCheckedOneRegion
().
id
);
.
setRegionId
(
getFilterModel
().
getCheckedOneRegion
()
!
.
id
);
}
else
{
getShopListModel
()
.
setRegionId
(
getFilterModel
().
getCheckedTwoRegion
().
id
);
.
setRegionId
(
getFilterModel
().
getCheckedTwoRegion
()
!
.
id
);
}
getShopListModel
().
setSortType
(
getFilterModel
().
getCheckedOneSort
().
id
);
getShopListModel
().
setSortType
(
getFilterModel
().
getCheckedOneSort
()
!
.
id
);
getShopListModel
().
clear
();
await
getShopListModel
().
refresh
();
getModel
().
notifyListeners
();
getModel
()
!
.
notifyListeners
();
}
catch
(
e
)
{}
if
(
loading
!=
null
)
{
loading
.
close
();
...
...
@@ -62,7 +62,7 @@ class IAction extends BaseAction<Model> {
}
void
refresh
()
async
{
String
cityId
=
getModel
()
.
getCityId
();
String
?
cityId
=
getModel
()!
.
getCityId
();
if
(
cityId
!=
null
&&
cityId
.
isNotEmpty
&&
...
...
lib/views/search/components/scroll_body.dart
View file @
6d6dc3e5
...
...
@@ -14,14 +14,14 @@ import 'package:life_module/route/index.dart';
import
'package:common_module/utils/xapp_utils.dart'
;
class
ScrollBody
extends
StatefulWidget
{
final
IAction
iAction
;
final
IAction
?
iAction
;
ScrollBody
(
this
.
iAction
);
@override
State
<
StatefulWidget
>
createState
()
=>
_ScrollBodyState
();
}
class
_ScrollBodyState
extends
State
<
ScrollBody
>
{
IAction
get
iAction
=>
widget
.
iAction
;
IAction
?
get
iAction
=>
widget
.
iAction
;
@override
void
initState
()
{
...
...
@@ -32,16 +32,16 @@ class _ScrollBodyState extends State<ScrollBody> {
Widget
build
(
BuildContext
context
)
{
return
Container
(
child:
QMProvider
.
value
(
model:
iAction
.
getShopListModel
(),
builderWidget:
(
context
,
model
,
child
)
{
model:
iAction
!
.
getShopListModel
(),
builderWidget:
(
context
,
dynamic
model
,
child
)
{
return
PullWidget
(
headerInsertIndex:
3
,
controller:
iAction
.
getShopListModel
().
getRefreshController
(),
controller:
iAction
!
.
getShopListModel
().
getRefreshController
(),
onLoad:
()
{
iAction
.
getShopListModel
().
getData
();
iAction
!
.
getShopListModel
().
getData
();
},
onRefresh:
()
{
iAction
.
getShopListModel
().
refresh
();
iAction
!
.
getShopListModel
().
refresh
();
},
child:
CustomScrollView
(
slivers:
[
...
...
@@ -51,9 +51,9 @@ class _ScrollBodyState extends State<ScrollBody> {
minHeight:
37
.
rpx
,
maxHeight:
37
.
rpx
,
child:
ShopTypeNav
(
model:
iAction
.
getFilterModel
(),
model:
iAction
!
.
getFilterModel
(),
onChange:
()
{
iAction
.
refreshShopList
();
iAction
!
.
refreshShopList
();
},
),
),
...
...
@@ -66,11 +66,11 @@ class _ScrollBodyState extends State<ScrollBody> {
maxHeight:
48
.
rpx
,
child:
FilterArea
(
topOffset:
81
.
rpx
-
37
.
rpx
,
model:
widget
.
iAction
.
getFilterModel
(),
model:
widget
.
iAction
!
.
getFilterModel
(),
onTap:
(
c
)
{
var
_context
=
widget
.
iAction
.
getShopListModel
().
getContext
()
;
RenderSliver
renderSliver
=
_context
widget
.
iAction
!.
getShopListModel
().
getContext
()!
;
RenderSliver
?
renderSliver
=
_context
.
findAncestorRenderObjectOfType
<
RenderSliver
>();
if
(
renderSliver
!=
null
&&
renderSliver
.
constraints
.
overlap
<=
0
)
{
...
...
@@ -78,7 +78,7 @@ class _ScrollBodyState extends State<ScrollBody> {
}
},
onChange:
()
{
widget
.
iAction
.
refreshShopList
();
widget
.
iAction
!
.
refreshShopList
();
},
))),
SliverPersistentHeader
(
...
...
@@ -87,20 +87,20 @@ class _ScrollBodyState extends State<ScrollBody> {
minHeight:
40
.
rpx
,
maxHeight:
40
.
rpx
,
child:
ShopClassNav
(
model:
widget
.
iAction
.
getFilterModel
(),
model:
widget
.
iAction
!
.
getFilterModel
(),
onChange:
()
{
widget
.
iAction
.
refreshShopList
();
widget
.
iAction
!
.
refreshShopList
();
},
))),
Builder
(
builder:
(
context
)
{
Widget
statusWidget
=
ListModelStatusUtils
.
getInstance
().
form
(
Widget
?
statusWidget
=
ListModelStatusUtils
.
getInstance
()
!
.
form
(
model:
model
,
onTap:
()
{
iAction
.
refresh
();
iAction
!
.
refresh
();
});
if
(
statusWidget
!=
null
)
{
return
SliverToBoxAdapter
(
...
...
@@ -108,33 +108,33 @@ class _ScrollBodyState extends State<ScrollBody> {
);
}
return
ShopList
(
model:
iAction
.
getShopListModel
(),
model:
iAction
!
.
getShopListModel
(),
onReset:
()
{
widget
.
iAction
.
getFilterModel
().
reset
();
widget
.
iAction
.
refreshShopList
();
widget
.
iAction
!
.
getFilterModel
().
reset
();
widget
.
iAction
!
.
refreshShopList
();
},
onTap:
(
item
)
{
NavigateUtils
.
push
(
path:
LIFE_SHOP_PAGE
,
arguments:
{
'shopId'
:
item
.
combo
!=
null
?
item
.
combo
.
shopId
:
item
.
restaurant
.
shopId
,
'lat'
:
widget
.
iAction
.
getModel
()
?
item
.
combo
!
.
shopId
:
item
.
restaurant
!
.
shopId
,
'lat'
:
widget
.
iAction
!
.
getModel
()
!
.
getLatitude
(),
'lng'
:
widget
.
iAction
.
getModel
()
'lng'
:
widget
.
iAction
!
.
getModel
()
!
.
getLongitude
(),
'firstCateId'
:
widget
.
iAction
'firstCateId'
:
widget
.
iAction
!
.
getFilterModel
()
.
getCheckedOneCategory
()
.
getCheckedOneCategory
()
!
.
id
,
'itemId'
:
item
.
combo
!=
null
?
item
.
combo
.
dealId
?
item
.
combo
!
.
dealId
:
""
,
"cityName"
:
widget
.
iAction
.
getModel
()
"cityName"
:
widget
.
iAction
!
.
getModel
()
!
.
getCityName
()
},
isNative:
false
,
...
...
lib/views/search/components/search_history.dart
View file @
6d6dc3e5
...
...
@@ -4,19 +4,19 @@ import 'package:life_module/components/life_image.dart';
import
'../../../util/search_history_utils.dart'
;
class
SearchHistory
extends
StatefulWidget
{
final
Function
(
String
)
onTap
;
final
Function
(
String
)
?
onTap
;
SearchHistory
({
this
.
onTap
});
@override
State
<
StatefulWidget
>
createState
()
=>
SearchHistoryState
();
}
class
SearchHistoryState
extends
State
<
SearchHistory
>
{
Function
(
String
)
get
onTap
=>
widget
.
onTap
;
Function
(
String
)
?
get
onTap
=>
widget
.
onTap
;
List
<
String
>
words
=
[];
@override
void
initState
()
{
super
.
initState
();
words
=
SearchHistoryUtils
.
getInstance
().
getWords
();
words
=
SearchHistoryUtils
.
getInstance
()
!
.
getWords
();
}
@override
...
...
@@ -42,7 +42,7 @@ class SearchHistoryState extends State<SearchHistory> {
),
),
onTap:
()
{
onTap
(
e
);
onTap
!
(
e
);
},
);
}).
toList
();
...
...
@@ -75,7 +75,7 @@ class SearchHistoryState extends State<SearchHistory> {
setState
(()
{
words
=
[];
});
SearchHistoryUtils
.
getInstance
().
clear
();
SearchHistoryUtils
.
getInstance
()
!
.
clear
();
},
child:
Container
(
height:
21
.
rpx
,
...
...
lib/views/search/components/search_tips.dart
View file @
6d6dc3e5
...
...
@@ -3,9 +3,9 @@ import 'package:common_module/utils/xapp_utils.dart';
import
'package:life_repository/life_repository.dart'
;
class
SearchTips
extends
StatelessWidget
{
final
String
keywords
;
final
List
<
SearchTipsItem
>
items
;
final
Function
(
SearchTipsItem
)
onTap
;
final
String
?
keywords
;
final
List
<
SearchTipsItem
>
?
items
;
final
Function
(
SearchTipsItem
)
?
onTap
;
SearchTips
({
this
.
items
,
this
.
keywords
,
this
.
onTap
});
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -13,12 +13,12 @@ class SearchTips extends StatelessWidget {
color:
Colors
.
white
,
child:
ListView
.
builder
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
13
.
rpx
),
itemCount:
items
.
length
,
itemCount:
items
!
.
length
,
itemBuilder:
(
context
,
index
)
{
var
item
=
items
[
index
];
List
<
String
>
names
=
item
.
name
.
split
(
""
);
var
item
=
items
!
[
index
];
List
<
String
>
names
=
item
.
name
!
.
split
(
""
);
List
<
TextSpan
>
childs
=
names
.
map
((
s
)
{
bool
isKeyWordChar
=
keywords
.
indexOf
(
s
)
>
-
1
;
bool
isKeyWordChar
=
keywords
!
.
indexOf
(
s
)
>
-
1
;
return
TextSpan
(
text:
s
,
style:
TextStyle
(
...
...
@@ -40,7 +40,7 @@ class SearchTips extends StatelessWidget {
),
),
onTap:
()
{
onTap
(
item
);
onTap
!
(
item
);
},
);
}),
...
...
lib/views/search/models/model.dart
View file @
6d6dc3e5
...
...
@@ -3,44 +3,44 @@ import 'dart:async';
import
'package:life_repository/life_repository.dart'
;
class
Model
extends
BaseModel
{
String
_cityId
=
''
;
String
_latitude
=
''
;
String
_longitude
=
''
;
String
?
_cityId
=
''
;
String
?
_latitude
=
''
;
String
?
_longitude
=
''
;
String
keywords
=
''
;
String
_cityName
;
Timer
_searchTipsTimer
;
String
?
_cityName
;
Timer
?
_searchTipsTimer
;
List
<
SearchTipsItem
>
_searchTipsList
=
[];
Model
(
this
.
_cityId
,
this
.
_latitude
,
this
.
_longitude
,
this
.
_cityName
);
String
getCityId
()
{
String
?
getCityId
()
{
return
_cityId
;
}
String
getLatitude
()
{
String
?
getLatitude
()
{
return
_latitude
;
}
String
getLongitude
()
{
String
?
getLongitude
()
{
return
_longitude
;
}
void
findSearchTips
(
String
firstCateId
,
String
words
)
{
void
findSearchTips
(
String
?
firstCateId
,
String
words
)
{
keywords
=
words
;
if
(
keywords
.
isEmpty
)
{
clearSearchTipsList
();
}
if
(
_searchTipsTimer
!=
null
&&
_searchTipsTimer
.
isActive
)
{
_searchTipsTimer
.
cancel
();
if
(
_searchTipsTimer
!=
null
&&
_searchTipsTimer
!
.
isActive
)
{
_searchTipsTimer
!
.
cancel
();
_searchTipsTimer
=
null
;
}
_searchTipsTimer
=
Timer
.
periodic
(
Duration
(
milliseconds:
500
),
(
timer
)
async
{
_searchTipsTimer
.
cancel
();
_searchTipsTimer
!
.
cancel
();
_searchTipsTimer
=
null
;
List
<
SearchTipsItem
>
list
=
await
FilterArepository
.
get
().
findSearchTips
(
_cityId
,
_latitude
,
_longitude
,
firstCateId
,
keywords
);
_cityId
!,
_latitude
!,
_longitude
!,
firstCateId
!
,
keywords
);
if
(
keywords
!=
null
&&
keywords
.
isNotEmpty
)
{
_searchTipsList
=
list
;
notifyListeners
();
...
...
@@ -62,7 +62,7 @@ class Model extends BaseModel {
return
keywords
;
}
String
getCityName
()
{
String
?
getCityName
()
{
return
_cityName
;
}
}
lib/views/search/view.dart
View file @
6d6dc3e5
...
...
@@ -3,6 +3,7 @@ import 'package:common_module/utils/xapp_utils.dart';
import
'package:common_module/components/i_app_bar.dart'
;
import
'package:life_module/components/search_bar.dart'
;
import
'package:life_module/utils/filter_panel_utils.dart'
;
import
'package:life_module/views/search/models/model.dart'
;
import
'./actions/action.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:mvp/providers/provider.dart'
;
...
...
@@ -12,25 +13,20 @@ import './components/search_history.dart';
import
'../../util/search_history_utils.dart'
;
class
LifeSearchPage
extends
StatefulWidget
{
final
Map
<
String
,
dynamic
>
param
;
final
Map
<
String
,
dynamic
>
?
param
;
LifeSearchPage
({
this
.
param
});
@override
State
<
StatefulWidget
>
createState
()
=>
_SearchPageState
();
}
class
_SearchPageState
extends
State
<
LifeSearchPage
>
with
TickerProviderStateMixin
{
IAction
iAction
;
class
_SearchPageState
extends
State
<
LifeSearchPage
>
with
TickerProviderStateMixin
{
IAction
?
iAction
;
FocusNode
focusNode
=
FocusNode
();
TextEditingController
controller
=
TextEditingController
();
@override
void
initState
()
{
super
.
initState
();
iAction
=
IAction
(
widget
.
param
[
'cityId'
],
widget
.
param
[
'latitude'
],
widget
.
param
[
'longitude'
],
widget
.
param
[
'cityName'
]);
iAction
=
IAction
(
widget
.
param
![
'cityId'
],
widget
.
param
![
'latitude'
],
widget
.
param
![
'longitude'
],
widget
.
param
![
'cityName'
]);
Future
.
delayed
(
Duration
(
milliseconds:
300
)).
then
((
value
)
{
focusNode
.
requestFocus
();
});
...
...
@@ -50,13 +46,13 @@ class _SearchPageState extends State<LifeSearchPage>
focusNode:
focusNode
,
controller:
controller
,
onChanged:
(
s
)
{
if
(
iAction
.
getFilterModel
().
getCheckedOneCategory
()
!=
null
)
{
iAction
.
getModel
()
.
findSearchTips
(
iAction
.
getFilterModel
().
getCheckedOneCategory
()
.
id
,
s
);
if
(
iAction
!
.
getFilterModel
().
getCheckedOneCategory
()
!=
null
)
{
iAction
!.
getModel
()!
.
findSearchTips
(
iAction
!.
getFilterModel
().
getCheckedOneCategory
()!
.
id
,
s
);
}
if
(
s
.
isEmpty
)
{
iAction
.
getShopListModel
().
setKeywords
(
""
);
iAction
.
getShopListModel
().
clear
();
iAction
!
.
getShopListModel
().
setKeywords
(
""
);
iAction
!
.
getShopListModel
().
clear
();
}
},
onSubmitted:
(
s
)
{
...
...
@@ -65,20 +61,20 @@ class _SearchPageState extends State<LifeSearchPage>
),
),
),
body:
ActionProvider
(
action:
iAction
,
body:
ActionProvider
<
Model
,
IAction
>
(
action:
iAction
!
,
builder:
(
context
,
model
)
{
if
(
iAction
.
getModel
()
.
getSearchTipsList
().
length
>
0
)
{
if
(
iAction
!.
getModel
()!
.
getSearchTipsList
().
length
>
0
)
{
return
SearchTips
(
items:
iAction
.
getModel
()
.
getSearchTipsList
(),
keywords:
iAction
.
getModel
()
.
getKeywords
(),
items:
iAction
!.
getModel
()!
.
getSearchTipsList
(),
keywords:
iAction
!.
getModel
()!
.
getKeywords
(),
onTap:
(
item
)
{
controller
.
text
=
item
.
name
;
iAction
.
getModel
()
.
clearSearchTipsList
();
search
(
item
.
name
);
controller
.
text
=
item
.
name
!
;
iAction
!.
getModel
()!
.
clearSearchTipsList
();
search
(
item
.
name
!
);
},
);
}
else
if
(
iAction
.
getShopListModel
().
getKeywords
().
isNotEmpty
)
{
}
else
if
(
iAction
!
.
getShopListModel
().
getKeywords
().
isNotEmpty
)
{
return
ScrollBody
(
iAction
);
}
return
SearchHistory
(
...
...
@@ -99,14 +95,14 @@ class _SearchPageState extends State<LifeSearchPage>
void
search
(
String
wrods
)
{
controller
.
text
=
wrods
;
iAction
.
getModel
()
.
clearSearchTipsList
();
SearchHistoryUtils
.
getInstance
().
push
(
wrods
);
iAction
!.
getModel
()!
.
clearSearchTipsList
();
SearchHistoryUtils
.
getInstance
()
!
.
push
(
wrods
);
focusNode
.
unfocus
();
iAction
.
getShopListModel
().
setKeywords
(
wrods
);
iAction
!
.
getShopListModel
().
setKeywords
(
wrods
);
if
(
wrods
.
isNotEmpty
)
{
iAction
.
refresh
();
iAction
!
.
refresh
();
}
else
{
iAction
.
getShopListModel
().
clear
();
iAction
!
.
getShopListModel
().
clear
();
}
}
}
lib/views/sec_kill/actions/action.dart
View file @
6d6dc3e5
...
...
@@ -4,14 +4,14 @@ import '../models/model.dart';
import
'../models/banner_model.dart'
;
class
IAction
extends
BaseAction
<
Model
>
{
String
_cityId
;
String
_showId
;
String
_lat
;
String
_lng
;
String
_cityName
;
String
?
_cityId
;
String
?
_showId
;
String
?
_lat
;
String
?
_lng
;
String
?
_cityName
;
SecKillModel
_killModel
;
BannerModel
_bannerModel
;
SecKillModel
?
_killModel
;
BannerModel
?
_bannerModel
;
IAction
(
this
.
_cityId
,
this
.
_showId
,
this
.
_lat
,
this
.
_lng
,
this
.
_cityName
);
...
...
@@ -24,50 +24,50 @@ class IAction extends BaseAction<Model> {
}
void
init
()
async
{
await
getModel
()
.
findSeckillSession
(
_cityId
);
if
(
_showId
==
null
||
_showId
.
isEmpty
)
{
_showId
=
getModel
().
getSeckillSessionList
()[
0
].
id
;
await
getModel
()
!.
findSeckillSession
(
_cityId
!
);
if
(
_showId
==
null
||
_showId
!
.
isEmpty
)
{
_showId
=
getModel
()
!
.
getSeckillSessionList
()[
0
].
id
;
}
getSecKillModel
().
setShowId
(
_showId
);
getSecKillModel
().
setCityId
(
_cityId
);
getSecKillModel
().
setLat
(
_lat
);
getSecKillModel
().
setLng
(
_lng
);
getSecKillModel
()
!
.
setShowId
(
_showId
);
getSecKillModel
()
!
.
setCityId
(
_cityId
);
getSecKillModel
()
!
.
setLat
(
_lat
);
getSecKillModel
()
!
.
setLng
(
_lng
);
refresh
();
getModel
().
findPermission
();
getModel
()
!
.
findPermission
();
}
void
refresh
()
async
{
await
getBannerModel
().
getActivityConfigList
();
await
getSecKillModel
().
refresh
();
await
getBannerModel
()
!
.
getActivityConfigList
();
await
getSecKillModel
()
!
.
refresh
();
}
void
setShowId
(
String
id
)
{
_showId
=
id
;
getSecKillModel
().
setShowId
(
id
);
getSecKillModel
().
clear
();
getSecKillModel
().
refresh
();
getSecKillModel
()
!
.
setShowId
(
id
);
getSecKillModel
()
!
.
clear
();
getSecKillModel
()
!
.
refresh
();
}
void
setLocaltionInfo
(
String
cityId
,
String
lat
,
String
lng
)
{
void
setLocaltionInfo
(
String
?
cityId
,
String
lat
,
String
lng
)
{
_cityId
=
cityId
;
_lat
=
lat
;
_lng
=
lng
;
_showId
=
null
;
getSecKillModel
().
clear
();
getModel
().
getSeckillSessionList
().
clear
();
getModel
().
notifyListeners
();
getSecKillModel
()
!
.
clear
();
getModel
()
!
.
getSeckillSessionList
().
clear
();
getModel
()
!
.
notifyListeners
();
init
();
}
String
getCityName
()
{
String
?
getCityName
()
{
return
_cityName
;
}
SecKillModel
getSecKillModel
()
{
SecKillModel
?
getSecKillModel
()
{
return
_killModel
;
}
BannerModel
getBannerModel
()
{
BannerModel
?
getBannerModel
()
{
return
_bannerModel
;
}
}
lib/views/sec_kill/components/ad_banner.dart
View file @
6d6dc3e5
...
...
@@ -7,15 +7,15 @@ import 'package:life_module/utils/activity_config_tap_utils.dart';
import
'package:flutter_swiper/flutter_swiper.dart'
;
class
AdBanner
extends
StatelessWidget
{
final
BannerModel
model
;
final
BannerModel
?
model
;
AdBanner
(
this
.
model
);
@override
Widget
build
(
BuildContext
context
)
{
ValueNotifier
<
int
>
scrollIndex
=
ValueNotifier
<
int
>(
0
);
ValueNotifier
<
int
?>
scrollIndex
=
ValueNotifier
<
int
?
>(
0
);
return
SliverToBoxAdapter
(
child:
QMProvider
<
BannerModel
>.
value
(
model:
model
,
model:
model
!
,
builderWidget:
(
context
,
model
,
child
)
{
if
(
model
.
getList
().
length
==
0
)
{
return
SizedBox
();
...
...
@@ -35,7 +35,7 @@ class AdBanner extends StatelessWidget {
model
.
getList
().
length
>
1
,
onTap:
(
index
)
{
var
item
=
model
.
getList
()[
index
];
AppTapConfigUtils
.
getInstance
().
activityConfigTap
(
item
.
toJson
());
AppTapConfigUtils
.
getInstance
()
!
.
activityConfigTap
(
item
.
toJson
());
},
onIndexChanged:
(
index
)
{
scrollIndex
.
value
=
index
;
...
...
@@ -43,7 +43,7 @@ class AdBanner extends StatelessWidget {
itemBuilder:
(
context
,
index
)
{
var
item
=
model
.
getList
()[
index
];
return
XiaoxiongBaseImageWidget
(
imageUrl:
item
.
imgUrl
,
imageUrl:
item
.
imgUrl
!
,
height:
90
.
rpx
,
fit:
BoxFit
.
cover
,
);
...
...
@@ -69,8 +69,8 @@ class AdBanner extends StatelessWidget {
/// 指示器
class
_SecKillPagination
extends
StatelessWidget
{
final
int
length
;
final
ValueNotifier
<
int
>
scrollIndex
;
final
int
?
length
;
final
ValueNotifier
<
int
?>?
scrollIndex
;
_SecKillPagination
({
this
.
scrollIndex
,
this
.
length
});
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -79,12 +79,12 @@ class _SecKillPagination extends StatelessWidget {
height:
4
.
rpx
,
);
}
return
ValueListenableBuilder
<
int
>(
valueListenable:
scrollIndex
,
builder:
(
BuildContext
context
,
dynamic
offset
,
Widget
child
)
{
List
<
Widget
>
items
=
List
.
generate
(
(
length
)
.
ceil
(),
(
index
)
{
return
ValueListenableBuilder
<
int
?
>(
valueListenable:
scrollIndex
!
,
builder:
(
BuildContext
context
,
dynamic
offset
,
Widget
?
child
)
{
List
<
Widget
>
items
=
List
.
generate
(
length
!
.
ceil
(),
(
index
)
{
Color
color
=
rgba
(
255
,
255
,
255
,
0.5
);
if
(
index
==
scrollIndex
.
value
)
{
if
(
index
==
scrollIndex
!
.
value
)
{
color
=
rgba
(
255
,
255
,
255
,
1
);
}
return
Container
(
...
...
lib/views/sec_kill/components/goods_items.dart
View file @
6d6dc3e5
...
...
@@ -12,16 +12,16 @@ import '../../../utils/buy_loading_dialog_utils.dart';
import
'package:common_module/utils/image_preview_utils.dart'
;
class
GoodsItems
extends
StatelessWidget
{
final
IAction
iAction
;
final
IAction
?
iAction
;
GoodsItems
(
this
.
iAction
);
@override
Widget
build
(
BuildContext
context
)
{
return
SliverPadding
(
padding:
EdgeInsets
.
zero
,
sliver:
QMProvider
<
SecKillModel
>.
value
(
model:
iAction
.
getSecKillModel
()
,
model:
iAction
!.
getSecKillModel
()!
,
builderWidget:
(
context
,
model
,
child
)
{
Widget
statusWidget
=
ListModelStatusUtils
.
getInstance
()
.
form
(
Widget
?
statusWidget
=
ListModelStatusUtils
.
getInstance
()!
.
form
(
model:
model
,
onTap:
()
{
model
.
refresh
();
...
...
@@ -48,9 +48,9 @@ class GoodsItems extends StatelessWidget {
}
class
_GoodsItem
extends
StatelessWidget
{
final
SecKillGoods
item
;
final
SecKillGoods
?
item
;
final
bool
enabled
;
final
IAction
iAction
;
final
IAction
?
iAction
;
_GoodsItem
({
this
.
enabled
=
false
,
this
.
item
,
this
.
iAction
});
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -73,8 +73,8 @@ class _GoodsItem extends StatelessWidget {
onTap:
()
{
ImagePreviewUtils
.
showIndex
(
context:
context
,
images:
[
item
.
itemPic
],
heroTag:
item
.
itemPic
);
images:
[
item
!.
itemPic
!
],
heroTag:
item
!
.
itemPic
);
},
child:
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
8
.
rpx
),
...
...
@@ -82,7 +82,7 @@ class _GoodsItem extends StatelessWidget {
height:
90
.
rpx
,
width:
90
.
rpx
,
child:
XiaoxiongBaseImageWidget
(
imageUrl:
item
.
itemPic
,
imageUrl:
item
!.
itemPic
!
,
height:
90
.
rpx
,
width:
90
.
rpx
,
fit:
BoxFit
.
cover
,
...
...
@@ -131,7 +131,7 @@ class _GoodsItem extends StatelessWidget {
/// 标题
class
_Title
extends
StatelessWidget
{
final
SecKillGoods
item
;
final
SecKillGoods
?
item
;
_Title
(
this
.
item
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -142,7 +142,7 @@ class _Title extends StatelessWidget {
Expanded
(
child:
Container
(
child:
Text
(
item
.
itemTitle
,
item
!.
itemTitle
!
,
maxLines:
1
,
overflow:
TextOverflow
.
ellipsis
,
style:
TextStyle
(
...
...
@@ -160,7 +160,7 @@ class _Title extends StatelessWidget {
}
class
_Commission
extends
StatelessWidget
{
final
SecKillGoods
item
;
final
SecKillGoods
?
item
;
_Commission
(
this
.
item
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -174,7 +174,7 @@ class _Commission extends StatelessWidget {
topRight:
Radius
.
circular
(
9
.
rpx
),
bottomRight:
Radius
.
circular
(
9
.
rpx
))),
child:
Text
(
item
.
userCommissionText
,
item
!.
userCommissionText
!
,
style:
TextStyle
(
color:
rgba
(
255
,
128
,
0
,
1
),
fontSize:
11
.
rpx
,
height:
1.2
),
),
...
...
@@ -184,7 +184,7 @@ class _Commission extends StatelessWidget {
/// 价格信息
class
_PriceInfo
extends
StatelessWidget
{
final
SecKillGoods
item
;
final
SecKillGoods
?
item
;
_PriceInfo
(
this
.
item
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -201,7 +201,7 @@ class _PriceInfo extends StatelessWidget {
),
),
Text
(
item
.
endPrice
,
item
!.
endPrice
!
,
style:
TextStyle
(
color:
rgba
(
255
,
4
,
0
,
1
),
fontSize:
18
.
rpx
,
height:
1.2
.
rpx
),
),
...
...
@@ -219,7 +219,7 @@ class _PriceInfo extends StatelessWidget {
width:
4
.
rpx
,
),
Text
(
"¥
${item.originalPrice}
"
,
"¥
${item
!
.originalPrice}
"
,
style:
TextStyle
(
color:
rgba
(
153
,
153
,
153
,
1
),
fontSize:
11
.
rpx
,
...
...
@@ -233,11 +233,11 @@ class _PriceInfo extends StatelessWidget {
/// 马上抢
class
_BuyBtn
extends
StatelessWidget
{
final
SecKillGoods
item
;
final
SecKillGoods
?
item
;
_BuyBtn
(
this
.
item
);
@override
Widget
build
(
BuildContext
context
)
{
bool
enabled
=
item
.
isRedirect
==
'2'
;
bool
enabled
=
item
!
.
isRedirect
==
'2'
;
return
Positioned
(
right:
0
,
bottom:
0
,
...
...
@@ -246,13 +246,13 @@ class _BuyBtn extends StatelessWidget {
child:
InkWell
(
onTap:
()
{
if
(
enabled
)
{
XAppUtils
.
getInstance
()
.
toast
(
item
.
menuText
);
XAppUtils
.
getInstance
()
!.
toast
(
item
!.
menuText
!
);
return
;
}
var
loading
=
BuyLoadingDialogUtils
.
getInstance
().
show
();
var
loading
=
BuyLoadingDialogUtils
.
getInstance
()
!
.
show
();
Future
.
delayed
(
Duration
(
seconds:
1
)).
then
((
value
)
{
loading
.
close
();
MeituanUtils
.
getInstance
()
.
openByUrl
(
item
.
couponUrl
);
MeituanUtils
.
getInstance
()
!.
openByUrl
(
item
!.
couponUrl
!
);
});
},
child:
Container
(
...
...
@@ -267,7 +267,7 @@ class _BuyBtn extends StatelessWidget {
colors:
[
rgba
(
255
,
128
,
0
,
1
),
rgba
(
255
,
4
,
0
,
1
)]),
borderRadius:
BorderRadius
.
circular
(
20
.
rpx
)),
child:
Text
(
item
.
menuText
,
item
!.
menuText
!
,
style:
TextStyle
(
color:
rgba
(
255
,
255
,
255
,
1
),
fontSize:
13
.
rpx
,
...
...
@@ -281,13 +281,13 @@ class _BuyBtn extends StatelessWidget {
/// 进度
class
_Progress
extends
StatelessWidget
{
final
SecKillGoods
item
;
final
SecKillGoods
?
item
;
_Progress
(
this
.
item
);
@override
Widget
build
(
BuildContext
context
)
{
double
maxWidth
=
154
.
rpx
;
double
whiteTextWidth
=
45
.
rpx
;
double
soldPercent
=
double
.
parse
(
item
.
soldPercent
.
replaceAll
(
'%'
,
''
));
double
soldPercent
=
double
.
parse
(
item
!.
soldPercent
!
.
replaceAll
(
'%'
,
''
));
double
p
=
soldPercent
/
100
*
maxWidth
;
bool
showWhiteText
=
p
>=
whiteTextWidth
;
return
Container
(
...
...
@@ -304,7 +304,7 @@ class _Progress extends StatelessWidget {
child:
showWhiteText
?
SizedBox
()
:
Text
(
"已抢
${item.soldPercent}
"
,
"已抢
${item
!
.soldPercent}
"
,
style:
TextStyle
(
color:
rgba
(
153
,
153
,
153
,
1
),
fontSize:
9
.
rpx
,
...
...
@@ -325,7 +325,7 @@ class _Progress extends StatelessWidget {
child:
!
showWhiteText
?
SizedBox
()
:
Text
(
"已抢
${item.soldPercent}
"
,
"已抢
${item
!
.soldPercent}
"
,
maxLines:
1
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
9
.
rpx
,
height:
1
.
rpx
),
...
...
@@ -339,8 +339,8 @@ class _Progress extends StatelessWidget {
/// 地址信息
class
_LocaionInfo
extends
StatelessWidget
{
final
SecKillGoods
item
;
final
IAction
iAction
;
final
SecKillGoods
?
item
;
final
IAction
?
iAction
;
_LocaionInfo
(
this
.
item
,
this
.
iAction
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -362,7 +362,7 @@ class _LocaionInfo extends StatelessWidget {
Container
(
constraints:
BoxConstraints
(
maxWidth:
260
.
rpx
),
child:
Text
(
item
.
address
,
item
!.
address
!
,
maxLines:
1
,
overflow:
TextOverflow
.
ellipsis
,
style:
TextStyle
(
...
...
@@ -378,7 +378,7 @@ class _LocaionInfo extends StatelessWidget {
),*/
Spacer
(),
Text
(
item
.
distance
,
item
!.
distance
!
,
style:
TextStyle
(
color:
rgba
(
153
,
153
,
153
,
1
),
fontSize:
12
.
rpx
,
...
...
lib/views/sec_kill/components/localtion_tips.dart
View file @
6d6dc3e5
...
...
@@ -7,8 +7,8 @@ import 'package:common_module/utils/loading_dialog_utils.dart';
import
'package:common_module/base/base_route_widget_state.dart'
;
class
LocaltionTips
extends
StatefulWidget
{
final
Model
model
;
final
Function
(
String
cityId
,
String
lat
,
String
lon
)
onLocationChange
;
final
Model
?
model
;
final
Function
(
String
?
cityId
,
String
lat
,
String
lon
)?
onLocationChange
;
LocaltionTips
({
this
.
model
,
this
.
onLocationChange
});
@override
...
...
@@ -16,10 +16,10 @@ class LocaltionTips extends StatefulWidget {
}
class
LocaltionTipsState
extends
BaseRouteWeigetState
<
LocaltionTips
>
{
Model
get
model
=>
widget
.
model
;
Model
?
get
model
=>
widget
.
model
;
@override
Widget
build
(
BuildContext
context
)
{
if
(
model
.
hasPermission
()
)
{
if
(
model
!.
hasPermission
()!
)
{
return
SliverToBoxAdapter
(
child:
SizedBox
(),
);
...
...
@@ -52,7 +52,7 @@ class LocaltionTipsState extends BaseRouteWeigetState<LocaltionTips> {
),
InkWell
(
onTap:
()
async
{
await
model
.
reqPermission
();
await
model
!
.
reqPermission
();
hasPermission
();
},
child:
Container
(
...
...
@@ -72,7 +72,7 @@ class LocaltionTipsState extends BaseRouteWeigetState<LocaltionTips> {
)),
InkWell
(
onTap:
()
{
model
.
setPermission
();
model
!
.
setPermission
();
},
child:
Container
(
width:
17
.
rpx
,
...
...
@@ -91,17 +91,17 @@ class LocaltionTipsState extends BaseRouteWeigetState<LocaltionTips> {
}
void
hasPermission
()
async
{
if
(
model
.
hasPermission
()
)
{
var
loading
=
LoadingDialogUtils
.
getInstance
().
show
();
if
(
model
!.
hasPermission
()!
)
{
var
loading
=
LoadingDialogUtils
.
getInstance
()
!
.
show
();
try
{
var
location
=
await
model
.
getLocation
();
var
location
=
await
model
!
.
getLocation
();
if
((
location
?.
address
??
''
).
isEmpty
){
String
myLocation
=
'
${location.longitude}
,
${location.latitude}
'
;
location
=
await
Res
.
convertLocation
(
entity:
location
,
location:
myLocation
);
}
var
cityId
=
await
model
.
findCityId
(
location
.
city
);
var
cityId
=
await
model
!.
findCityId
(
location
.
city
!
);
loading
.
close
();
widget
.
onLocationChange
(
cityId
,
location
.
latitude
.
toString
(),
widget
.
onLocationChange
!
(
cityId
,
location
.
latitude
.
toString
(),
location
.
longitude
.
toString
());
}
catch
(
e
)
{
loading
.
close
();
...
...
@@ -112,8 +112,8 @@ class LocaltionTipsState extends BaseRouteWeigetState<LocaltionTips> {
@override
void
onResume
()
async
{
super
.
onResume
();
if
(!
model
.
hasPermission
()
)
{
await
model
.
findPermission
();
if
(!
model
!.
hasPermission
()!
)
{
await
model
!
.
findPermission
();
hasPermission
();
}
}
...
...
lib/views/sec_kill/components/times.dart
View file @
6d6dc3e5
...
...
@@ -6,9 +6,9 @@ import 'package:mvp/mvp.dart';
import
'../models/sec_kill_model.dart'
;
class
Times
extends
StatefulWidget
{
final
IAction
iAction
;
final
List
<
SeckillSession
>
times
;
final
Function
(
String
tid
)
onChange
;
final
IAction
?
iAction
;
final
List
<
SeckillSession
>
?
times
;
final
Function
(
String
?
tid
)?
onChange
;
Times
({
this
.
iAction
,
this
.
times
,
this
.
onChange
});
@override
State
<
StatefulWidget
>
createState
()
=>
_TimesState
();
...
...
@@ -24,7 +24,7 @@ class _TimesState extends State<Times> {
@override
Widget
build
(
BuildContext
context
)
{
return
QMProvider
<
SecKillModel
>.
value
(
model:
widget
.
iAction
.
getSecKillModel
()
,
model:
widget
.
iAction
!.
getSecKillModel
()!
,
builderWidget:
(
context
,
module
,
child
)
{
return
Container
(
height:
64
.
rpx
,
...
...
@@ -36,17 +36,17 @@ class _TimesState extends State<Times> {
padding:
EdgeInsets
.
symmetric
(
horizontal:
9
.
rpx
),
scrollDirection:
Axis
.
horizontal
,
itemBuilder:
(
context
,
i
)
{
var
item
=
widget
.
times
[
i
];
var
item
=
widget
.
times
!
[
i
];
Color
timeColor
=
rgba
(
48
,
38
,
0
,
1
);
Color
statusColor
=
rgba
(
102
,
102
,
102
,
1
);
double
timeSize
=
20
.
rpx
;
List
<
String
>
timeArr
=
item
.
text
.
split
(
"-"
);
List
<
String
>
timeArr
=
item
.
text
!
.
split
(
"-"
);
String
timeText
=
timeArr
[
0
];
String
statusText
=
item
.
statusText
;
String
?
timeText
=
timeArr
[
0
];
String
statusText
=
item
.
statusText
!
;
bool
isSelected
=
widget
.
iAction
.
getSecKillModel
()
.
getShowId
()
==
item
.
id
;
widget
.
iAction
!.
getSecKillModel
()!
.
getShowId
()
==
item
.
id
;
if
(
isSelected
)
{
timeColor
=
Colors
.
white
;
statusColor
=
Colors
.
white
;
...
...
@@ -64,15 +64,15 @@ class _TimesState extends State<Times> {
return
InkWell
(
onTap:
()
{
if
(
widget
.
iAction
.
getSecKillModel
()
.
getShowId
()
==
item
.
id
)
{
if
(
widget
.
iAction
!.
getSecKillModel
()!
.
getShowId
()
==
item
.
id
)
{
return
;
}
if
(
widget
.
iAction
.
getSecKillModel
()
.
viewState
!=
if
(
widget
.
iAction
!.
getSecKillModel
()!
.
viewState
!=
ViewState
.
idle
)
{
return
;
}
widget
.
onChange
(
item
.
id
);
widget
.
onChange
!
(
item
.
id
);
},
child:
Container
(
width:
100
.
rpx
,
...
...
@@ -98,7 +98,7 @@ class _TimesState extends State<Times> {
Container
(
height:
18
.
rpx
,
child:
Text
(
timeText
,
timeText
!
,
style:
TextStyle
(
color:
timeColor
,
fontSize:
timeSize
,
...
...
@@ -123,7 +123,7 @@ class _TimesState extends State<Times> {
),
);
},
itemCount:
widget
.
times
.
length
,
itemCount:
widget
.
times
!
.
length
,
),
);
},
...
...
lib/views/sec_kill/models/model.dart
View file @
6d6dc3e5
import
'dart:async'
;
import
'package:mvp/mvp.dart'
;
import
'package:common_module/utils/amap_utils.dart'
;
import
'package:modal/modal.dart'
;
import
'package:life_repository/life_repository.dart'
;
class
Model
extends
BaseModel
{
bool
_hasPermission
=
true
;
bool
?
_hasPermission
=
true
;
List
<
SeckillSession
>
_seckillSessionList
=
[];
Future
<
void
>
findPermission
()
async
{
_hasPermission
=
await
AmapUtils
.
getInstance
().
hasPermission
();
if
(
_hasPermission
)
{
_hasPermission
=
await
AmapUtils
.
getInstance
().
isOpenGPS
;
_hasPermission
=
await
AmapUtils
.
getInstance
()
!
.
hasPermission
();
if
(
_hasPermission
!
)
{
_hasPermission
=
await
AmapUtils
.
getInstance
()
!
.
isOpenGPS
;
}
notifyListeners
();
}
bool
hasPermission
()
{
bool
?
hasPermission
()
{
return
_hasPermission
;
}
...
...
@@ -29,10 +31,10 @@ class Model extends BaseModel {
}
Future
<
LocationEntity
>
getLocation
()
{
return
AmapUtils
.
getInstance
().
getLocation
();
return
AmapUtils
.
getInstance
()
!
.
getLocation
();
}
Future
<
String
>
findCityId
(
String
city
)
async
{
Future
<
String
?
>
findCityId
(
String
city
)
async
{
return
CityRepository
.
get
().
getCityId
(
city
);
}
...
...
@@ -43,28 +45,28 @@ class Model extends BaseModel {
}
Future
<
void
>
reqPermission
()
async
{
bool
confirm
=
await
Modal
.
showModal
(
bool
confirm
=
await
(
Modal
.
showModal
(
title:
"温馨提示"
,
msg:
"为给您提供更好的服务,需获取您的位置权限"
,
cancelBtnText:
'拒绝'
,
confirmBtnText:
'同意'
);
confirmBtnText:
'同意'
)
as
FutureOr
<
bool
>)
;
if
(!
confirm
)
{
return
;
}
_hasPermission
=
await
AmapUtils
.
getInstance
().
reqPermission
();
_hasPermission
=
await
AmapUtils
.
getInstance
()
!
.
reqPermission
();
if
(
_hasPermission
)
{
_hasPermission
=
await
AmapUtils
.
getInstance
().
isOpenGPS
;
if
(!
_hasPermission
)
{
confirm
=
await
Modal
.
showModal
(
if
(
_hasPermission
!
)
{
_hasPermission
=
await
AmapUtils
.
getInstance
()
!
.
isOpenGPS
;
if
(!
_hasPermission
!
)
{
confirm
=
await
(
Modal
.
showModal
(
title:
"温馨提示"
,
msg:
"为给您提供更好的服务,请打开GPS"
,
cancelBtnText:
'拒绝'
,
confirmBtnText:
'同意'
);
confirmBtnText:
'同意'
)
as
FutureOr
<
bool
>)
;
if
(!
confirm
)
{
return
;
}
_hasPermission
=
await
AmapUtils
.
getInstance
().
enableGPS
();
_hasPermission
=
await
AmapUtils
.
getInstance
()
!
.
enableGPS
();
}
}
notifyListeners
();
...
...
lib/views/sec_kill/models/sec_kill_model.dart
View file @
6d6dc3e5
...
...
@@ -2,10 +2,10 @@ import 'package:mvp/mvp.dart';
import
'package:life_repository/life_repository.dart'
;
class
SecKillModel
extends
BaseListModel
<
SecKillGoods
>
{
String
_cityId
;
String
_showId
;
String
_lat
;
String
_lng
;
String
?
_cityId
;
String
?
_showId
;
String
?
_lat
;
String
?
_lng
;
SecKillModel
(
this
.
_cityId
,
this
.
_showId
,
this
.
_lat
,
this
.
_lng
);
...
...
@@ -13,28 +13,28 @@ class SecKillModel extends BaseListModel<SecKillGoods> {
Future
<
List
<
SecKillGoods
>>
request
()
async
{
viewState
=
ViewState
.
busy
;
var
res
=
await
SecKillRepository
.
get
()
.
findSeckillGoodsList
(
_cityId
,
_showId
,
_lat
,
_lng
,
getPage
());
.
findSeckillGoodsList
(
_cityId
!,
_showId
!,
_lat
!,
_lng
!
,
getPage
());
viewState
=
ViewState
.
idle
;
return
res
;
}
void
setShowId
(
String
id
)
{
void
setShowId
(
String
?
id
)
{
_showId
=
id
;
}
String
getShowId
()
{
String
?
getShowId
()
{
return
_showId
;
}
void
setCityId
(
String
cityId
)
{
void
setCityId
(
String
?
cityId
)
{
_cityId
=
cityId
;
}
void
setLat
(
String
lat
)
{
void
setLat
(
String
?
lat
)
{
_lat
=
lat
;
}
void
setLng
(
String
lng
)
{
void
setLng
(
String
?
lng
)
{
_lng
=
lng
;
}
...
...
lib/views/sec_kill/view.dart
View file @
6d6dc3e5
...
...
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import
'package:common_module/components/i_app_bar.dart'
;
import
'package:common_module/utils/xapp_utils.dart'
;
import
'package:life_module/components/life_image.dart'
;
import
'package:life_module/views/sec_kill/models/model.dart'
;
import
'./components/times.dart'
;
import
'./components/ad_banner.dart'
;
import
'./components/localtion_tips.dart'
;
...
...
@@ -12,21 +13,21 @@ import 'package:common_module/widget/pull_widget/widget.dart';
import
'package:flutter/cupertino.dart'
;
class
LifeSecKillPage
extends
StatefulWidget
{
final
Map
<
String
,
dynamic
>
param
;
final
Map
<
String
,
dynamic
>
?
param
;
LifeSecKillPage
({
this
.
param
});
@override
State
<
StatefulWidget
>
createState
()
=>
_LifeSecKillPageState
();
}
class
_LifeSecKillPageState
extends
State
<
LifeSecKillPage
>
{
String
get
tid
=>
widget
.
param
[
'tid'
];
String
?
get
tid
=>
widget
.
param
!
[
'tid'
];
IAction
iAction
;
IAction
?
iAction
;
@override
void
initState
()
{
super
.
initState
();
iAction
=
IAction
(
widget
.
param
[
'cityId'
],
tid
,
widget
.
param
[
'lat'
],
widget
.
param
[
'lng'
],
widget
.
param
[
'cityName'
]);
iAction
=
IAction
(
widget
.
param
![
'cityId'
],
tid
,
widget
.
param
!
[
'lat'
],
widget
.
param
![
'lng'
],
widget
.
param
!
[
'cityName'
]);
}
@override
...
...
@@ -46,10 +47,10 @@ class _LifeSecKillPageState extends State<LifeSecKillPage> {
),
),
),
body:
ActionProvider
(
action:
iAction
,
body:
ActionProvider
<
Model
,
IAction
>
(
action:
iAction
!
,
builder:
(
context
,
child
)
{
if
(
iAction
.
getModel
()
.
getSeckillSessionList
().
length
==
0
)
{
if
(
iAction
!.
getModel
()!
.
getSeckillSessionList
().
length
==
0
)
{
return
Container
(
alignment:
Alignment
.
center
,
child:
CupertinoActivityIndicator
(
radius:
10
.
rpx
),
...
...
@@ -59,28 +60,28 @@ class _LifeSecKillPageState extends State<LifeSecKillPage> {
children:
[
Times
(
iAction:
iAction
,
times:
iAction
.
getModel
()
.
getSeckillSessionList
(),
times:
iAction
!.
getModel
()!
.
getSeckillSessionList
(),
onChange:
(
tid
)
{
iAction
.
setShowId
(
tid
);
iAction
!.
setShowId
(
tid
!
);
},
),
Expanded
(
child:
Container
(
child:
PullWidget
(
controller:
iAction
.
getSecKillModel
()
.
getRefreshController
(),
controller:
iAction
!.
getSecKillModel
()!
.
getRefreshController
(),
onLoad:
()
{
iAction
.
getSecKillModel
()
.
getData
();
iAction
!.
getSecKillModel
()!
.
getData
();
},
onRefresh:
()
{
iAction
.
refresh
();
iAction
!
.
refresh
();
},
child:
CustomScrollView
(
slivers:
[
AdBanner
(
iAction
.
getBannerModel
()),
AdBanner
(
iAction
!
.
getBannerModel
()),
LocaltionTips
(
model:
iAction
.
getModel
(),
model:
iAction
!
.
getModel
(),
onLocationChange:
(
cityId
,
lat
,
lon
)
{
iAction
.
setLocaltionInfo
(
cityId
,
lat
,
lon
);
iAction
!
.
setLocaltionInfo
(
cityId
,
lat
,
lon
);
},
),
SliverToBoxAdapter
(
...
...
lib/views/shop/actions/action.dart
View file @
6d6dc3e5
...
...
@@ -3,15 +3,15 @@ import '../models/model.dart';
import
'../models/outer_info_model.dart'
;
class
IAction
extends
BaseAction
<
Model
>
{
String
shopId
;
String
lat
;
String
lng
;
String
firstCateId
;
String
itemId
;
final
String
_cityName
;
OuterInfoModel
_outerInfoModel
;
String
?
shopId
;
String
?
lat
;
String
?
lng
;
String
?
firstCateId
;
String
?
itemId
;
final
String
?
_cityName
;
OuterInfoModel
?
_outerInfoModel
;
Function
()
load
;
Function
()
?
load
;
IAction
(
this
.
shopId
,
this
.
lat
,
this
.
lng
,
this
.
firstCateId
,
this
.
itemId
,
this
.
_cityName
);
...
...
@@ -23,10 +23,10 @@ class IAction extends BaseAction<Model> {
}
void
init
()
async
{
await
getModel
().
findShopDetail
();
await
getOuterInfoModel
().
findShopOuterInfo
();
await
getModel
()
!
.
findShopDetail
();
await
getOuterInfoModel
()
!
.
findShopOuterInfo
();
if
(
load
!=
null
)
{
load
();
load
!
();
}
}
...
...
@@ -34,11 +34,11 @@ class IAction extends BaseAction<Model> {
load
=
cb
;
}
String
getFirstCateId
()
{
String
?
getFirstCateId
()
{
return
firstCateId
;
}
OuterInfoModel
getOuterInfoModel
()
{
OuterInfoModel
?
getOuterInfoModel
()
{
return
_outerInfoModel
;
}
}
lib/views/shop/components/appraise_items.dart
View file @
6d6dc3e5
...
...
@@ -6,12 +6,12 @@ import 'package:mvp/mvp.dart';
import
'package:flutter/cupertino.dart'
;
class
AppraiseItems
extends
StatelessWidget
{
final
OuterInfoModel
model
;
final
OuterInfoModel
?
model
;
AppraiseItems
(
this
.
model
);
@override
Widget
build
(
BuildContext
context
)
{
return
QMProvider
<
OuterInfoModel
>.
value
(
model:
model
,
model:
model
!
,
builderWidget:
(
context
,
model
,
child
)
{
if
(
model
.
getShopOuterInfoEntity
()
==
null
)
{
return
SliverToBoxAdapter
(
...
...
@@ -24,7 +24,7 @@ class AppraiseItems extends StatelessWidget {
));
}
var
list
=
model
.
getShopOuterInfoEntity
().
commentItemEntitys
;
var
list
=
model
.
getShopOuterInfoEntity
()
!
.
commentItemEntitys
;
if
(
list
.
length
==
0
)
{
return
SliverToBoxAdapter
(
child:
Container
(
...
...
lib/views/shop/components/footer_explain.dart
View file @
6d6dc3e5
...
...
@@ -14,7 +14,7 @@ class FooterExplain extends StatelessWidget {
InkWell
(
onTap:
()
{
Map
<
String
,
dynamic
>
map
=
{
'redirect_type'
:
'11'
};
AppTapConfigUtils
.
getInstance
().
activityConfigTap
(
map
);
AppTapConfigUtils
.
getInstance
()
!
.
activityConfigTap
(
map
);
},
child:
Container
(
padding:
EdgeInsets
.
only
(
top:
12
.
rpx
,
bottom:
4
.
rpx
),
...
...
lib/views/shop/components/goods_items.dart
View file @
6d6dc3e5
...
...
@@ -9,7 +9,7 @@ import '../../../utils/buy_loading_dialog_utils.dart';
import
'package:common_module/utils/image_preview_utils.dart'
;
class
GoodsItems
extends
StatelessWidget
{
final
Model
model
;
final
Model
?
model
;
GoodsItems
(
this
.
model
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -19,22 +19,22 @@ class GoodsItems extends StatelessWidget {
return
_GoodsItem
(
isFirst:
index
==
0
,
isLast:
index
==
1
,
item:
model
.
getShopInfoEntity
().
shopCouponItems
[
index
],
item:
model
!.
getShopInfoEntity
()!.
shopCouponItems
!
[
index
],
);
},
childCount:
model
.
getShopInfoEntity
().
shopCouponItems
.
length
,
childCount:
model
!.
getShopInfoEntity
()!.
shopCouponItems
!
.
length
,
));
}
}
class
_GoodsItem
extends
StatelessWidget
{
final
bool
isFirst
;
final
bool
isLast
;
final
ShopCouponItem
item
;
final
bool
?
isFirst
;
final
bool
?
isLast
;
final
ShopCouponItem
?
item
;
_GoodsItem
({
this
.
isFirst
,
this
.
isLast
,
this
.
item
});
@override
Widget
build
(
BuildContext
context
)
{
double
top
=
isFirst
?
16
.
rpx
:
12
.
rpx
;
double
top
=
isFirst
!
?
16
.
rpx
:
12
.
rpx
;
return
Container
(
height:
90
.
rpx
+
top
,
...
...
@@ -42,7 +42,7 @@ class _GoodsItem extends StatelessWidget {
left:
12
.
rpx
,
right:
12
.
rpx
,
top:
top
,
bottom:
16
.
rpx
),
decoration:
BoxDecoration
(
color:
Colors
.
white
,
borderRadius:
BorderRadius
.
vertical
(
bottom:
Radius
.
circular
(
isLast
?
8
.
rpx
:
0
))),
borderRadius:
BorderRadius
.
vertical
(
bottom:
Radius
.
circular
(
isLast
!
?
8
.
rpx
:
0
))),
child:
Row
(
children:
[
InkWell
(
...
...
@@ -52,7 +52,7 @@ class _GoodsItem extends StatelessWidget {
height:
74
.
rpx
,
width:
74
.
rpx
,
child:
XiaoxiongBaseImageWidget
(
imageUrl:
item
.
itemImg
,
imageUrl:
item
!.
itemImg
!
,
height:
74
.
rpx
,
width:
74
.
rpx
,
fit:
BoxFit
.
cover
,
...
...
@@ -61,8 +61,8 @@ class _GoodsItem extends StatelessWidget {
onTap:
()
{
ImagePreviewUtils
.
showIndex
(
context:
context
,
images:
[
item
.
itemImg
],
heroTag:
item
.
itemImg
);
images:
[
item
!.
itemImg
!
],
heroTag:
item
!
.
itemImg
);
},
),
SizedBox
(
...
...
@@ -100,7 +100,7 @@ class _GoodsItem extends StatelessWidget {
/// 标题
class
_Title
extends
StatelessWidget
{
final
ShopCouponItem
item
;
final
ShopCouponItem
?
item
;
_Title
(
this
.
item
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -109,7 +109,7 @@ class _Title extends StatelessWidget {
child:
Row
(
children:
[
TypeIcon
(
type:
int
.
parse
(
item
.
dealType
),
type:
int
.
parse
(
item
!.
dealType
!
),
),
SizedBox
(
width:
4
.
rpx
,
...
...
@@ -117,7 +117,7 @@ class _Title extends StatelessWidget {
Expanded
(
child:
Container
(
child:
Text
(
item
.
itemTitle
,
item
!.
itemTitle
!
,
maxLines:
1
,
overflow:
TextOverflow
.
ellipsis
,
style:
TextStyle
(
...
...
@@ -135,11 +135,11 @@ class _Title extends StatelessWidget {
}
class
_Commission
extends
StatelessWidget
{
final
ShopCouponItem
item
;
final
ShopCouponItem
?
item
;
_Commission
(
this
.
item
);
@override
Widget
build
(
BuildContext
context
)
{
if
(
double
.
parse
(
item
.
userCommission
)
==
0
)
{
if
(
double
.
parse
(
item
!.
userCommission
!
)
==
0
)
{
Container
(
height:
18
.
rpx
);
}
return
Container
(
...
...
@@ -152,7 +152,7 @@ class _Commission extends StatelessWidget {
topRight:
Radius
.
circular
(
9
.
rpx
),
bottomRight:
Radius
.
circular
(
9
.
rpx
))),
child:
Text
(
item
.
userCommissionText
,
item
!.
userCommissionText
!
,
style:
TextStyle
(
color:
rgba
(
255
,
128
,
0
,
1
),
fontSize:
11
.
rpx
,
height:
1.2
),
),
...
...
@@ -162,7 +162,7 @@ class _Commission extends StatelessWidget {
/// 价格信息
class
_PriceInfo
extends
StatelessWidget
{
final
ShopCouponItem
item
;
final
ShopCouponItem
?
item
;
_PriceInfo
(
this
.
item
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -179,7 +179,7 @@ class _PriceInfo extends StatelessWidget {
),
),
Text
(
item
.
endPrice
,
item
!.
endPrice
!
,
style:
TextStyle
(
color:
rgba
(
255
,
4
,
0
,
1
),
fontSize:
16
.
rpx
,
...
...
@@ -189,7 +189,7 @@ class _PriceInfo extends StatelessWidget {
width:
4
.
rpx
,
),
Text
(
"¥
${item.originalPrice}
"
,
"¥
${item
!
.originalPrice}
"
,
style:
TextStyle
(
color:
rgba
(
153
,
153
,
153
,
1
),
fontSize:
12
.
rpx
,
...
...
@@ -204,7 +204,7 @@ class _PriceInfo extends StatelessWidget {
color:
rgba
(
255
,
128
,
0
,
0.06
),
borderRadius:
BorderRadius
.
circular
(
34
.
rpx
)),
child:
Text
(
"
${item.discountPercent}
折"
,
"
${item
!
.discountPercent}
折"
,
style:
TextStyle
(
color:
rgba
(
255
,
128
,
0
,
1
),
fontSize:
11
.
rpx
,
height:
1
.
rpx
),
),
...
...
@@ -216,7 +216,7 @@ class _PriceInfo extends StatelessWidget {
}
class
_BuyBtn
extends
StatelessWidget
{
final
ShopCouponItem
item
;
final
ShopCouponItem
?
item
;
_BuyBtn
(
this
.
item
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -241,10 +241,10 @@ class _BuyBtn extends StatelessWidget {
),
),
onTap:
()
{
var
loading
=
BuyLoadingDialogUtils
.
getInstance
().
show
();
var
loading
=
BuyLoadingDialogUtils
.
getInstance
()
!
.
show
();
Future
.
delayed
(
Duration
(
seconds:
1
)).
then
((
value
)
{
loading
.
close
();
MeituanUtils
.
getInstance
()
.
openByUrl
(
item
.
couponUrl
);
MeituanUtils
.
getInstance
()
!.
openByUrl
(
item
!.
couponUrl
!
);
});
},
);
...
...
lib/views/shop/components/nav_bar.dart
View file @
6d6dc3e5
...
...
@@ -4,8 +4,8 @@ import 'package:navigation_bar/navigation_bar.dart';
import
'package:life_module/components/persistent_header_delegate.dart'
;
class
NavBar
extends
StatelessWidget
{
final
TabController
controller
;
final
Function
(
int
)
onChange
;
final
TabController
?
controller
;
final
Function
(
int
)
?
onChange
;
NavBar
({
this
.
controller
,
this
.
onChange
});
@override
Widget
build
(
BuildContext
context
)
{
...
...
lib/views/shop/components/recommend.dart
View file @
6d6dc3e5
...
...
@@ -7,7 +7,7 @@ import 'package:flutter/cupertino.dart';
import
'package:common_module/utils/image_preview_utils.dart'
;
class
Recommend
extends
StatelessWidget
{
final
OuterInfoModel
model
;
final
OuterInfoModel
?
model
;
Recommend
(
this
.
model
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -19,7 +19,7 @@ class Recommend extends StatelessWidget {
color:
Colors
.
white
,
borderRadius:
BorderRadius
.
vertical
(
bottom:
Radius
.
circular
(
8
.
rpx
))),
child:
QMProvider
<
OuterInfoModel
>.
value
(
model:
model
,
model:
model
!
,
builderWidget:
(
context
,
model
,
child
)
{
if
(
model
.
getShopOuterInfoEntity
()
==
null
)
{
return
Container
(
...
...
@@ -29,7 +29,7 @@ class Recommend extends StatelessWidget {
),
);
}
if
(
model
.
getShopOuterInfoEntity
().
recommendItemEntitys
.
length
==
0
)
{
if
(
model
.
getShopOuterInfoEntity
()
!
.
recommendItemEntitys
.
length
==
0
)
{
return
Container
(
alignment:
Alignment
.
center
,
padding:
EdgeInsets
.
only
(
bottom:
15
.
rpx
,
top:
10
.
rpx
),
...
...
@@ -44,13 +44,13 @@ class Recommend extends StatelessWidget {
);
}
List
<
Widget
>
items
=
model
.
getShopOuterInfoEntity
().
recommendItemEntitys
.
map
((
e
)
{
model
.
getShopOuterInfoEntity
()
!
.
recommendItemEntitys
.
map
((
e
)
{
return
Expanded
(
child:
InkWell
(
onTap:
()
{
ImagePreviewUtils
.
showIndex
(
context:
context
,
images:
[
e
.
itemPic
],
images:
[
e
.
itemPic
!
],
heroTag:
e
.
itemPic
);
},
child:
Container
(
...
...
@@ -60,11 +60,11 @@ class Recommend extends StatelessWidget {
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
8
.
rpx
),
child:
Hero
(
tag:
e
.
itemPic
,
tag:
e
.
itemPic
!
,
child:
XiaoxiongBaseImageWidget
(
height:
75
.
rpx
,
width:
100
.
rpx
,
imageUrl:
e
.
itemPic
,
imageUrl:
e
.
itemPic
!
,
fit:
BoxFit
.
cover
,
),
)),
...
...
@@ -75,7 +75,7 @@ class Recommend extends StatelessWidget {
height:
17
.
rpx
,
alignment:
Alignment
.
centerLeft
,
child:
Text
(
e
.
itemTitle
,
e
.
itemTitle
!
,
style:
TextStyle
(
color:
rgba
(
48
,
38
,
0
,
1
),
fontSize:
12
.
rpx
,
...
...
lib/views/shop/components/shop_info.dart
View file @
6d6dc3e5
...
...
@@ -9,7 +9,7 @@ import 'package:common_module/utils/audit_mode_utils.dart';
import
'package:common_module/utils/image_preview_utils.dart'
;
class
ShopInfo
extends
StatelessWidget
{
final
Model
model
;
final
Model
?
model
;
ShopInfo
(
this
.
model
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -26,7 +26,7 @@ class ShopInfo extends StatelessWidget {
height:
12
.
rpx
,
),
_Location
(
model
),
AuditModeUtils
.
getInstance
().
isAuditMode
()
AuditModeUtils
.
getInstance
()
!
.
isAuditMode
()
?
SizedBox
()
:
Container
(
height:
48
.
rpx
,
...
...
@@ -44,7 +44,7 @@ class ShopInfo extends StatelessWidget {
/// 店铺展示信息
class
_ShopInfo
extends
StatelessWidget
{
final
Model
model
;
final
Model
?
model
;
_ShopInfo
(
this
.
model
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -56,7 +56,7 @@ class _ShopInfo extends StatelessWidget {
alignment:
Alignment
.
centerLeft
,
padding:
EdgeInsets
.
only
(
top:
12
.
rpx
,
bottom:
10
.
rpx
),
child:
Text
(
model
.
getShopInfoEntity
().
shopInfo
.
shopTitle
,
model
!.
getShopInfoEntity
()!.
shopInfo
!.
shopTitle
!
,
style:
TextStyle
(
color:
rgba
(
48
,
38
,
0
,
1
),
fontSize:
18
.
rpx
,
height:
1
.
rpx
,
fontWeight:
FontWeight
.
w600
),
),
...
...
@@ -72,7 +72,7 @@ class _ShopInfo extends StatelessWidget {
height:
80
.
rpx
,
width:
80
.
rpx
,
child:
XiaoxiongBaseImageWidget
(
imageUrl:
model
.
getShopInfoEntity
().
shopInfo
.
shopImg
,
imageUrl:
model
!.
getShopInfoEntity
()!.
shopInfo
!.
shopImg
!
,
height:
80
.
rpx
,
width:
80
.
rpx
,
fit:
BoxFit
.
cover
,
...
...
@@ -81,8 +81,8 @@ class _ShopInfo extends StatelessWidget {
onTap:
()
{
ImagePreviewUtils
.
showIndex
(
context:
context
,
images:
[
model
.
getShopInfoEntity
().
shopInfo
.
shopImg
],
heroTag:
model
.
getShopInfoEntity
().
shopInfo
.
shopImg
);
images:
[
model
!.
getShopInfoEntity
()!.
shopInfo
!.
shopImg
!
],
heroTag:
model
!.
getShopInfoEntity
()!.
shopInfo
!
.
shopImg
);
},
),
SizedBox
(
...
...
@@ -100,7 +100,7 @@ class _ShopInfo extends StatelessWidget {
Container
(
height:
16
.
rpx
,
child:
Text
(
"¥
${model
.getShopInfoEntity().shopInfo
.avgPrice}
/人"
,
"¥
${model
!.getShopInfoEntity()!.shopInfo!
.avgPrice}
/人"
,
style:
TextStyle
(
color:
rgba
(
102
,
102
,
102
,
1
),
fontSize:
11
.
rpx
),
...
...
@@ -124,7 +124,7 @@ class _ShopInfo extends StatelessWidget {
Container
(
height:
16
.
rpx
,
child:
Text
(
"营业时间
${model
.getShopInfoEntity().shopInfo
.businessTime}
"
,
"营业时间
${model
!.getShopInfoEntity()!.shopInfo!
.businessTime}
"
,
style:
TextStyle
(
color:
rgba
(
48
,
38
,
0
,
1
),
fontSize:
12
.
rpx
),
),
...
...
@@ -144,11 +144,11 @@ class _ShopInfo extends StatelessWidget {
/// 评分和距离信息
class
_ScoreInfo
extends
StatelessWidget
{
final
Model
model
;
final
Model
?
model
;
_ScoreInfo
(
this
.
model
);
@override
Widget
build
(
BuildContext
context
)
{
var
showStarScore
=
model
.
getShopInfoEntity
().
shopInfo
.
showStarScore
;
var
showStarScore
=
model
!.
getShopInfoEntity
()!.
shopInfo
!.
showStarScore
!
;
List
<
InlineSpan
>
widgets
=
[];
double
score
=
double
.
parse
(
showStarScore
);
for
(
int
star
=
1
,
len
=
score
.
ceil
();
star
<=
len
;
star
++)
{
...
...
@@ -185,7 +185,7 @@ class _ScoreInfo extends StatelessWidget {
),
Container
(
child:
Text
(
double
.
parse
(
model
.
getShopInfoEntity
().
shopInfo
.
commentScore
)
double
.
parse
(
model
!.
getShopInfoEntity
()!.
shopInfo
!.
commentScore
!
)
.
toStringAsFixed
(
1
),
style:
TextStyle
(
color:
rgba
(
255
,
128
,
0
,
1
),
...
...
@@ -195,7 +195,7 @@ class _ScoreInfo extends StatelessWidget {
),
Spacer
(),
Text
(
model
.
getShopInfoEntity
().
shopInfo
.
distance
,
model
!.
getShopInfoEntity
()!.
shopInfo
!.
distance
!
,
style:
TextStyle
(
color:
rgba
(
102
,
102
,
102
,
1
),
fontSize:
11
.
rpx
),
)
],
...
...
@@ -206,7 +206,7 @@ class _ScoreInfo extends StatelessWidget {
/// 位置信息
class
_Location
extends
StatelessWidget
{
final
Model
model
;
final
Model
?
model
;
_Location
(
this
.
model
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -225,7 +225,7 @@ class _Location extends StatelessWidget {
Expanded
(
child:
Container
(
child:
Text
(
model
.
getShopInfoEntity
().
shopInfo
.
address
,
model
!.
getShopInfoEntity
()!.
shopInfo
!.
address
!
,
style:
TextStyle
(
color:
rgba
(
48
,
38
,
0
,
1
),
fontSize:
12
.
rpx
),
),
),
...
...
@@ -236,7 +236,7 @@ class _Location extends StatelessWidget {
InkWell
(
onTap:
()
{
ClipboardUtils
.
copyText
(
model
.
getShopInfoEntity
().
shopInfo
.
address
);
model
!.
getShopInfoEntity
()!.
shopInfo
!.
address
!
);
FlutterNativeToast
.
showToast
(
'门店地址已复制'
);
},
child:
Container
(
...
...
lib/views/shop/models/model.dart
View file @
6d6dc3e5
import
'dart:async'
;
import
'package:mvp/mvp.dart'
;
import
'package:life_repository/life_repository.dart'
;
class
Model
extends
BaseModel
{
final
String
_cityName
;
final
String
_shopId
;
final
String
_lat
;
final
String
_lng
;
final
String
_itemId
;
ShopInfoEntity
_shopInfoEntity
;
final
String
?
_cityName
;
final
String
?
_shopId
;
final
String
?
_lat
;
final
String
?
_lng
;
final
String
?
_itemId
;
ShopInfoEntity
?
_shopInfoEntity
;
Model
(
this
.
_shopId
,
this
.
_lat
,
this
.
_lng
,
this
.
_cityName
,
this
.
_itemId
);
Future
<
void
>
findShopDetail
()
async
{
var
data
=
await
ShopInfoRepository
.
get
().
findShopDetail
(
_shopId
,
_lat
,
_lng
);
await
(
ShopInfoRepository
.
get
().
findShopDetail
(
_shopId
!,
_lat
!,
_lng
!)
as
FutureOr
<
ShopInfoEntity
>
);
var
list
=
data
.
shopCouponItems
;
if
(
_itemId
!=
null
&&
_itemId
.
isNotEmpty
)
{
if
(
_itemId
!=
null
&&
_itemId
!
.
isNotEmpty
)
{
try
{
var
index
=
list
.
indexWhere
((
item
)
{
var
index
=
list
!
.
indexWhere
((
item
)
{
return
item
.
dealId
==
_itemId
;
});
if
(
index
>
-
1
)
{
...
...
@@ -29,11 +30,11 @@ class Model extends BaseModel {
notifyListeners
();
}
ShopInfoEntity
getShopInfoEntity
()
{
ShopInfoEntity
?
getShopInfoEntity
()
{
return
_shopInfoEntity
;
}
String
getCityName
()
{
String
?
getCityName
()
{
return
_cityName
;
}
}
lib/views/shop/models/outer_info_model.dart
View file @
6d6dc3e5
...
...
@@ -2,18 +2,18 @@ import 'package:mvp/mvp.dart';
import
'package:life_repository/life_repository.dart'
;
class
OuterInfoModel
extends
BaseModel
{
final
String
_shopId
;
final
String
_firstCateId
;
ShopOuterInfoEntity
_outerInfoEntity
;
final
String
?
_shopId
;
final
String
?
_firstCateId
;
ShopOuterInfoEntity
?
_outerInfoEntity
;
OuterInfoModel
(
this
.
_shopId
,
this
.
_firstCateId
);
Future
<
void
>
findShopOuterInfo
()
async
{
_outerInfoEntity
=
await
ShopInfoRepository
.
get
().
findShopOuterInfo
(
_shopId
,
_firstCateId
);
await
ShopInfoRepository
.
get
().
findShopOuterInfo
(
_shopId
!,
_firstCateId
!
);
notifyListeners
();
}
ShopOuterInfoEntity
getShopOuterInfoEntity
()
{
ShopOuterInfoEntity
?
getShopOuterInfoEntity
()
{
return
_outerInfoEntity
;
}
}
lib/views/shop/view.dart
View file @
6d6dc3e5
...
...
@@ -16,7 +16,7 @@ import '../../utils/share_dialog_utils.dart';
import
'components/appraise_items.dart'
;
class
LifeShopPage
extends
StatefulWidget
{
final
Map
<
String
,
dynamic
>
param
;
final
Map
<
String
,
dynamic
>
?
param
;
LifeShopPage
({
this
.
param
});
@override
State
<
StatefulWidget
>
createState
()
=>
_LifeShopPageState
();
...
...
@@ -24,29 +24,29 @@ class LifeShopPage extends StatefulWidget {
class
_LifeShopPageState
extends
State
<
LifeShopPage
>
with
TickerProviderStateMixin
{
TabController
tabController
;
IAction
iAction
;
TabController
?
tabController
;
late
IAction
iAction
;
ScrollController
controller
=
ScrollController
();
GlobalKey
globalKey1
=
GlobalKey
();
GlobalKey
globalKey2
=
GlobalKey
();
GlobalKey
globalKey3
=
GlobalKey
();
double
offset1
;
double
offset2
;
double
offset3
;
double
?
offset1
;
late
double
offset2
;
late
double
offset3
;
bool
isTap
=
false
;
@override
void
initState
()
{
super
.
initState
();
var
param
=
widget
.
param
;
var
param
=
widget
.
param
!
;
iAction
=
IAction
(
param
[
'shopId'
],
param
[
'lat'
],
param
[
'lng'
],
param
[
'firstCateId'
],
param
[
'itemId'
],
param
[
'cityName'
]);
iAction
.
onLoad
(()
{
Future
.
delayed
(
Duration
(
milliseconds:
500
)).
then
((
value
)
{
RenderBox
renderBox1
=
globalKey1
.
currentContext
.
findRenderObject
()
;
RenderBox
renderBox2
=
globalKey2
.
currentContext
.
findRenderObject
()
;
RenderBox
renderBox3
=
globalKey3
.
currentContext
.
findRenderObject
()
;
RenderBox
renderBox1
=
globalKey1
.
currentContext
!.
findRenderObject
()
as
RenderBox
;
RenderBox
renderBox2
=
globalKey2
.
currentContext
!.
findRenderObject
()
as
RenderBox
;
RenderBox
renderBox3
=
globalKey3
.
currentContext
!.
findRenderObject
()
as
RenderBox
;
offset1
=
renderBox1
.
localToGlobal
(
Offset
(
0
,
0
)).
dy
;
offset2
=
renderBox2
.
localToGlobal
(
Offset
(
0
,
0
)).
dy
;
offset3
=
renderBox3
.
localToGlobal
(
Offset
(
0
,
0
)).
dy
;
...
...
@@ -60,11 +60,11 @@ class _LifeShopPageState extends State<LifeShopPage>
var
size
=
MediaQuery
.
of
(
context
).
padding
;
var
offset
=
controller
.
offset
+
104
.
rpx
+
size
.
top
;
if
(
offset
>=
offset3
)
{
tabController
.
animateTo
(
2
);
tabController
!
.
animateTo
(
2
);
}
else
if
(
offset
>=
offset2
)
{
tabController
.
animateTo
(
1
);
tabController
!
.
animateTo
(
1
);
}
else
{
tabController
.
animateTo
(
0
);
tabController
!
.
animateTo
(
0
);
}
});
}
...
...
@@ -76,7 +76,7 @@ class _LifeShopPageState extends State<LifeShopPage>
appBar:
IAppBar
(
title:
"全部优惠"
,
color:
Colors
.
white
,
actions:
AuditModeUtils
.
getInstance
().
isAuditMode
()?
null
:[
actions:
AuditModeUtils
.
getInstance
()
!
.
isAuditMode
()?
null
:[
InkWell
(
child:
Container
(
width:
54
.
rpx
,
...
...
@@ -88,13 +88,13 @@ class _LifeShopPageState extends State<LifeShopPage>
),
),
onTap:
()
{
if
(
iAction
.
getModel
().
getShopInfoEntity
()
==
null
)
{
if
(
iAction
.
getModel
()
!
.
getShopInfoEntity
()
==
null
)
{
return
;
}
ShareDialogUtils
.
getInstance
().
show
(
ShareDialogUtils
.
getInstance
()
!
.
show
(
context:
context
,
firstCateId:
iAction
.
getFirstCateId
(),
shopInfo:
iAction
.
getModel
()
.
getShopInfoEntity
()
.
shopInfo
);
shopInfo:
iAction
.
getModel
()
!.
getShopInfoEntity
()!
.
shopInfo
);
},
)
],
...
...
@@ -102,7 +102,7 @@ class _LifeShopPageState extends State<LifeShopPage>
body:
ActionProvider
(
action:
iAction
,
builder:
(
context
,
child
)
{
if
(
iAction
.
getModel
().
getShopInfoEntity
()
==
null
)
{
if
(
iAction
.
getModel
()
!
.
getShopInfoEntity
()
==
null
)
{
return
Container
(
padding:
EdgeInsets
.
only
(
top:
100
.
rpx
),
alignment:
Alignment
.
topCenter
,
...
...
@@ -123,13 +123,13 @@ class _LifeShopPageState extends State<LifeShopPage>
isTap
=
true
;
if
(
index
==
0
)
{
await
Scrollable
.
ensureVisible
(
globalKey1
.
currentContext
);
globalKey1
.
currentContext
!
);
}
else
if
(
index
==
1
)
{
await
Scrollable
.
ensureVisible
(
globalKey2
.
currentContext
);
globalKey2
.
currentContext
!
);
}
else
if
(
index
==
2
)
{
await
Scrollable
.
ensureVisible
(
globalKey3
.
currentContext
);
globalKey3
.
currentContext
!
);
}
isTap
=
false
;
},
...
...
pubspec.yaml
View file @
6d6dc3e5
...
...
@@ -6,7 +6,7 @@ homepage: /
publish_to
:
none
environment
:
sdk
:
"
>=2.7.0
<3.0.0"
sdk
:
'
>=2.12.0
<3.0.0'
flutter
:
"
>=1.17.0"
dependencies
:
...
...
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