天气详情页

master
章文轩 4 years ago
parent 47c88bfb22
commit 418ac64dcc

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

@ -0,0 +1,408 @@
import 'package:extended_image/extended_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:recook/models/home_weather_model.dart';
import 'package:recook/widgets/alert.dart';
import 'package:recook/widgets/custom_app_bar.dart';
import 'package:get/get.dart';
import 'package:recook/constants/styles.dart';
import 'package:recook/constants/header.dart';
import 'package:recook/widgets/recook_back_button.dart';
import 'package:velocity_x/velocity_x.dart';
class HomeWeatherDetailPage extends StatefulWidget {
final HomeWeatherModel homeWeatherModel;
HomeWeatherDetailPage({
Key key,
this.homeWeatherModel,
}) : super(key: key);
@override
_HomeWeatherDetailPageState createState() => _HomeWeatherDetailPageState();
}
class _HomeWeatherDetailPageState extends State<HomeWeatherDetailPage> {
HomeWeatherModel _homeWeatherModel;
@override
void initState() {
super.initState();
_homeWeatherModel = widget.homeWeatherModel;
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColor.frenchColor,
resizeToAvoidBottomInset: false,
appBar: CustomAppBar(
appBackground: Colors.white,
leading: RecookBackButton(
white: false,
),
// flexibleSpace: Container(
// width: double.infinity,
// height: 34.rw,
// decoration: BoxDecoration(
// borderRadius:
// BorderRadius.only(bottomRight: Radius.circular(104.rw)),
// color: _getBarColor(_homeWeatherModel.weaImg),
// ),
// ),
elevation: 0,
title: Text(
"天气",
style: TextStyle(
color: Color(0xFF333333),
fontSize: 18.rsp,
),
),
),
body: Container(
child: _bodyWidget(),
),
);
}
_bodyWidget() {
return ListView(
children: [
Container(
child: Container(
width: double.infinity,
height: 379.rw,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(_getBackGroud(_homeWeatherModel.weaImg)),
fit: BoxFit.fill)),
child: (Column(
children: [
140.hb,
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
_homeWeatherModel.city,
style: TextStyle(fontSize: 20.rsp, color: Colors.white),
),
5.wb,
Image.asset(
R.ASSETS_WEATHER_WEATHER_LOCATION_PNG,
width: 20.rw,
height: 19.5.rw,
)
],
),
12.hb,
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'°C',
style: TextStyle(
fontSize: 35.rsp, color: Colors.transparent),
),
Text(
_homeWeatherModel.tem,
style: TextStyle(fontSize: 90.rsp, color: Colors.white),
),
Text(
'°C',
style: TextStyle(fontSize: 35.rsp, color: Colors.white),
),
],
),
14.hb,
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
_homeWeatherModel.tem1,
style: TextStyle(fontSize: 18.rsp, color: Colors.white),
),
Text(
'°C',
style: TextStyle(fontSize: 18.rsp, color: Colors.white),
),
Text(
'/',
style: TextStyle(fontSize: 18.rsp, color: Colors.white),
),
Text(
_homeWeatherModel.tem2,
style: TextStyle(fontSize: 18.rsp, color: Colors.white),
),
Text(
'°C',
style: TextStyle(fontSize: 18.rsp, color: Colors.white),
),
],
),
12.hb,
Text(
_homeWeatherModel.wea,
style: TextStyle(fontSize: 18.rsp, color: Colors.white),
),
Spacer(),
Row(
children: [
Spacer(),
Text(
'空气',
style: TextStyle(fontSize: 18.rsp, color: Colors.white),
),
Text(
_homeWeatherModel.airLevel,
style: TextStyle(fontSize: 18.rsp, color: Colors.white),
),
20.wb,
],
),
Row(
children: [
GestureDetector(
onTap: _homeWeatherModel.alarm.alarmContent != ''
? () {
Alert.show(
context,
NormalTextDialog(
title: '预警',
content:
_homeWeatherModel.alarm.alarmContent,
titleColor: Color(0xFFEE0000),
//deleteItem: '确认',
items: ['确认'],
type: NormalTextDialogType.normal,
listener: (_) => Navigator.pop(context),
// deleteListener: () =>
// Navigator.pop(context, true),
));
}
: () {
Alert.show(
context,
NormalTextDialog(
title: '预警',
content: '暂无预警发布',
//deleteItem: '确认',
items: ['确认'],
type: NormalTextDialogType.normal,
listener: (_) => Navigator.pop(context),
// deleteListener: () =>
// Navigator.pop(context, true),
));
},
child: Row(
children: [
30.wb,
Text(
'天气预警',
style: TextStyle(
fontSize: 14.rsp, color: Colors.white),
),
Image.asset(
R.ASSETS_WEATHER_WEATHER_WANING_PNG,
height: 14.rw,
width: 16.rw,
),
],
),
),
Spacer(),
Text(
'气象台更新时间:',
style: TextStyle(fontSize: 14.rsp, color: Colors.white),
),
Text(
_homeWeatherModel.updateTime,
style: TextStyle(fontSize: 14.rsp, color: Colors.white),
),
20.wb,
],
),
22.hb,
],
)),
),
),
Container(
width: double.infinity,
color: _getColor(_homeWeatherModel.weaImg),
child: Column(
children: [
_getDivider(),
_bottomItem('湿度', '能见度', _homeWeatherModel.humidity,
_homeWeatherModel.visibility),
_getDivider(),
_bottomItem1(),
_getDivider(),
_bottomItem('PM2.5', 'PM10', _homeWeatherModel.aqi.pm25Desc,
_homeWeatherModel.aqi.pm10Desc),
_getDivider(),
_bottomItem('O3', 'NO2', _homeWeatherModel.aqi.o3Desc,
_homeWeatherModel.aqi.no2Desc),
_getDivider(),
_bottomItem('SO2', '是否需要佩戴口罩', _homeWeatherModel.aqi.so2Desc,
_homeWeatherModel.aqi.kouzhao),
_getDivider(),
_bottomItem('风向', '风速', _homeWeatherModel.win,
_homeWeatherModel.winSpeed),
_getDivider(),
_bottomItem('外出适宜', '开窗适宜', _homeWeatherModel.aqi.waichu,
_homeWeatherModel.aqi.kaichuang),
],
),
)
],
);
}
_getDivider() {
return Divider(
height: 1.rw,
color: Colors.white,
indent: 10.rw,
endIndent: 10.rw,
);
}
_bottomItem1() {
return Container(
height: 78.rw,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
30.wb,
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 70.rw,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'空气质量',
style: TextStyle(color: Colors.white, fontSize: 16.rsp),
),
Text(
_homeWeatherModel.airLevel,
style: TextStyle(color: Colors.white, fontSize: 26.rsp),
)
],
),
)
],
),
64.wb,
Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
_homeWeatherModel.airTips,
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: Colors.white, fontSize: 12.rsp),
),
],
).expand()
],
));
}
_bottomItem(String title1, String title2, String content1, String content2) {
return Container(
height: 78.rw,
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
30.wb,
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
title1,
style: TextStyle(color: Colors.white, fontSize: 16.rsp),
),
Text(
content1,
style: TextStyle(color: Colors.white, fontSize: 26.rsp),
)
],
).expand(),
80.wb,
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
title1,
style: TextStyle(color: Colors.white, fontSize: 16.rsp),
),
Text(
content1,
style: TextStyle(color: Colors.white, fontSize: 26.rsp),
)
],
).expand()
],
));
}
_getBackGroud(String weather) {
switch (weather) {
case 'xue':
return R.ASSETS_WEATHER_XUN_BG_JPG;
case 'lei':
return R.ASSETS_WEATHER_LEI_BG_JPG;
case 'shachen':
return R.ASSETS_WEATHER_SHACHEN_BG_JPG;
case 'wu':
return R.ASSETS_WEATHER_WU_BG_JPG;
case 'bingbao':
return R.ASSETS_WEATHER_BINGBAO_BG_JPG;
case 'yun':
return R.ASSETS_WEATHER_YUN_BG_JPG;
case 'yu':
return R.ASSETS_WEATHER_YU_BG_JPG;
case 'yin':
return R.ASSETS_WEATHER_YIN_BG_JPG;
case 'qing':
return R.ASSETS_WEATHER_QING_BG_JPG;
}
}
_getColor(String weather) {
switch (weather) {
case 'xue':
return Color(0xFF27080E);
case 'lei':
return Color(0xFF112027);
case 'shachen':
return Color(0xFFDC721C);
case 'wu':
return Color(0xFF013358);
case 'bingbao':
return Color(0xFF141D24);
case 'yun':
return Color(0xFF599BE9);
case 'yu':
return Color(0xFF414954);
case 'yin':
return Color(0xFF373F4A);
case 'qing':
return Color(0xFF64A8F1);
}
}
}

@ -51,7 +51,7 @@ class HomeWeatherWidgetState extends State<HomeWeatherWidget>
return GestureDetector(
onTap: () {
Get.to(HomeWeatherDetailPage());
Get.to(HomeWeatherDetailPage(homeWeatherModel:widget.homeWeatherModel));
},
child: Container(
color: _backgroundColor,

@ -53,6 +53,7 @@ enum NormalTextDialogType { normal, delete, remind }
///
class NormalTextDialog extends Dialog {
final Color titleColor;
final String title;
final String content;
final String deleteItem;
@ -63,6 +64,7 @@ class NormalTextDialog extends Dialog {
const NormalTextDialog(
{this.title,
this.titleColor,
this.content,
this.deleteItem = "删除",
this.items,
@ -97,7 +99,7 @@ class NormalTextDialog extends Dialog {
child: Text(
this.title,
style: TextStyle(
color: Colors.black,
color: titleColor == null ? Colors.black : titleColor,
fontSize: 16 * 2.sp,
fontWeight: FontWeight.w600),
),

@ -415,34 +415,13 @@ class GoodsItemWidget extends StatelessWidget {
return Container(
width: _height - 8,
height: _height - 8,
decoration: BoxDecoration(
color: AppColor.frenchColor,
borderRadius: BorderRadius.all(Radius.circular(cir)),
),
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(cir)),
child: Stack(children: [
living?.status == 1
? Positioned(
top: 6.rw,
right: 6.rw,
child: Container(
width: 25.rw,
height: 16.rw,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8.rw)),
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [
Color(0xFFEC4073),
Color(0xFFE50043),
],
)),
child: Row(
children: [
LiveAnimateWidget(),
],
),
),
)
: SizedBox(),
Positioned(
top: 0,
right: 0,
@ -475,6 +454,31 @@ class GoodsItemWidget extends StatelessWidget {
),
),
),
living?.status == 1
? Positioned(
top: 6.rw,
right: 6.rw,
child: Container(
width: 25.rw,
height: 16.rw,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8.rw)),
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [
Color(0xFFEC4073),
Color(0xFFE50043),
],
)),
child: Row(
children: [
LiveAnimateWidget(),
],
),
),
)
: SizedBox(),
isSingleDayGoods
? Positioned(
left: 0,
@ -923,10 +927,11 @@ class GoodsItemWidget extends StatelessWidget {
buyClick();
} else {
AppRouter.push(buildCtx, RouteName.COMMODITY_PAGE,
arguments: CommodityDetailPage.setArguments(this.id,
// liveStatus: living == null ? null : living.status,
// roomId: living == null ? null : living.roomId
));
arguments: CommodityDetailPage.setArguments(
this.id,
// liveStatus: living == null ? null : living.status,
// roomId: living == null ? null : living.roomId
));
}
}

@ -108,7 +108,8 @@ class _ShareGoodsPosterPageState extends BaseStoreState<ShareGoodsPosterPage> {
bigImageUrl: _bigImageUrl,
goodsDetailModel: _goodsDetail,
)),
)
),
],
),
);

@ -303,6 +303,7 @@ flutter:
- assets/shop/
- assets/header/
- assets/live/
- assets/weather/
fonts:
- family: AppIcons
fonts:

Loading…
Cancel
Save