weather indicator updated
parent
648d9d245d
commit
7d3c1ac852
@ -1,106 +1,56 @@
|
|||||||
import 'package:diplomaticquarterapp/core/model/contactus/get_hmg_locations.dart';
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
||||||
import 'package:diplomaticquarterapp/core/viewModels/contactus/findus_view_model.dart';
|
import 'package:diplomaticquarterapp/core/viewModels/weather/weather_view_model.dart';
|
||||||
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/location_util.dart';
|
||||||
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||||
import 'package:diplomaticquarterapp/widgets/buttons/button.dart';
|
|
||||||
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
|
||||||
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
||||||
import 'package:diplomaticquarterapp/widgets/slider/slider.dart';
|
|
||||||
import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart';
|
import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/weather_slider/weather_slider.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_xlider/flutter_xlider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:giffy_dialog/giffy_dialog.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
import 'package:maps_launcher/maps_launcher.dart';
|
|
||||||
|
|
||||||
class HealthWeatherIndicator extends StatefulWidget {
|
class HealthWeatherIndicator extends StatefulWidget {
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_HospitalsPageState createState() => _HospitalsPageState();
|
_HospitalsPageState createState() => _HospitalsPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class _HospitalsPageState extends State<HealthWeatherIndicator> {
|
class _HospitalsPageState extends State<HealthWeatherIndicator> {
|
||||||
LinearGradient gradient = LinearGradient(
|
var data;
|
||||||
colors: <Color> [
|
LocationUtils locationUtils;
|
||||||
Colors.red,
|
@override
|
||||||
Colors.orange,
|
void initState() {
|
||||||
Colors.yellow,
|
locationUtils =
|
||||||
Colors.green,
|
new LocationUtils(isShowConfirmDialog: true, context: context);
|
||||||
Colors.blue,
|
WidgetsBinding.instance
|
||||||
Colors.blue[900],
|
.addPostFrameCallback((_) => locationUtils.getCurrentLocation());
|
||||||
Colors.purple
|
|
||||||
]
|
super.initState();
|
||||||
);
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return AppScaffold(
|
|
||||||
isShowDecPage: false,
|
|
||||||
appBarTitle: TranslationBase.of(context).healthWeatherIndicators,
|
|
||||||
isShowAppBar: true,
|
|
||||||
body: SingleChildScrollView(
|
|
||||||
child: Column(children: [
|
|
||||||
WeatherSlider(.4, LinearGradient(colors: [Colors.redAccent[100],Colors.redAccent ])),
|
|
||||||
WeatherSlider(.6, LinearGradient(colors: [Colors.greenAccent[100],Colors.greenAccent ])),
|
|
||||||
WeatherSlider(.8, LinearGradient(colors: [Colors.yellowAccent[100],Colors.yellowAccent ])),
|
|
||||||
])
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class WeatherSlider extends StatelessWidget{
|
|
||||||
final width;
|
|
||||||
final LinearGradient color;
|
|
||||||
WeatherSlider(this.width, this.color);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// TODO: implement build
|
ProjectViewModel projectViewModel = Provider.of(context);
|
||||||
return Column(
|
return BaseView<WeatherViewModel>(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
onModelReady: (model) => model.getWeatherData(),
|
||||||
children: [
|
builder: (_, mode, widget) => AppScaffold(
|
||||||
AppText('Low', fontSize: 24,),
|
isShowDecPage: false,
|
||||||
|
appBarTitle: TranslationBase.of(context).healthWeatherIndicators,
|
||||||
Padding(
|
isShowAppBar: true,
|
||||||
padding: EdgeInsets.all(10),
|
baseViewModel: mode,
|
||||||
child:
|
body: mode.weatherIndicatorData.length>0 ? SingleChildScrollView(
|
||||||
Stack(
|
child: Column(children: [
|
||||||
children: [
|
Padding(padding: EdgeInsets.all(15), child:AppText( projectViewModel.isArabic ? mode.weatherIndicatorData[0].cityNameN : mode.weatherIndicatorData[0].cityName, fontSize: 24, fontWeight: FontWeight.bold,)),
|
||||||
Container(
|
Padding(
|
||||||
decoration: BoxDecoration(gradient: LinearGradient(colors: [Colors.grey[100],Colors.grey[400] ]),
|
padding: EdgeInsets.all(15),
|
||||||
borderRadius: BorderRadius.circular(10)
|
child: Column(children:
|
||||||
),
|
mode.weatherIndicatorData
|
||||||
height: 15, width: MediaQuery.of(context).size.width,
|
.map((data) {
|
||||||
child:SizedBox(),
|
return WeatherSlider(
|
||||||
),
|
data);
|
||||||
Positioned(
|
}).toList()
|
||||||
top:0,
|
|
||||||
child: Container(
|
))])) : Container(child:AppText('Loading...'))),
|
||||||
decoration: BoxDecoration(gradient: color,
|
);
|
||||||
borderRadius: BorderRadius.circular(10)
|
|
||||||
),
|
|
||||||
height: 15,
|
|
||||||
width: MediaQuery.of(context).size.width * width,
|
|
||||||
padding: EdgeInsets.all(10),
|
|
||||||
child:SizedBox(),
|
|
||||||
|
|
||||||
)),
|
|
||||||
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
AppText('Low', fontSize: 12,),
|
|
||||||
AppText('Moderate', fontSize: 12,),
|
|
||||||
AppText('High', fontSize: 12,),
|
|
||||||
AppText('Very High', fontSize: 12,),
|
|
||||||
AppText('Extreme', fontSize: 12,),
|
|
||||||
],)
|
|
||||||
],);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,55 +1,191 @@
|
|||||||
|
import 'package:diplomaticquarterapp/core/model/weahter/weather_model.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class WeatherSlider extends StatelessWidget {
|
||||||
class WeatherSlider extends StatelessWidget{
|
// final width;
|
||||||
final width;
|
// final LinearGradient color;
|
||||||
final LinearGradient color;
|
final GetCityInfoList data;
|
||||||
WeatherSlider(this.width, this.color);
|
WeatherSlider(this.data);
|
||||||
|
LinearGradient red = LinearGradient(
|
||||||
|
colors: [
|
||||||
|
Colors.redAccent[100],
|
||||||
|
Colors.redAccent
|
||||||
|
]);
|
||||||
|
LinearGradient green = LinearGradient(
|
||||||
|
colors: [
|
||||||
|
Colors.greenAccent[100],
|
||||||
|
Colors.greenAccent
|
||||||
|
]);
|
||||||
|
LinearGradient grey = LinearGradient(
|
||||||
|
colors: [
|
||||||
|
Colors.grey[100],
|
||||||
|
Colors.grey
|
||||||
|
]);
|
||||||
|
LinearGradient orange = LinearGradient(
|
||||||
|
colors: [
|
||||||
|
Colors.orangeAccent[100],
|
||||||
|
Colors.orange
|
||||||
|
]);
|
||||||
|
LinearGradient yellow = LinearGradient(
|
||||||
|
colors: [
|
||||||
|
Colors.yellow[100],
|
||||||
|
Colors.yellow[600]
|
||||||
|
]);
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// TODO: implement build
|
// TODO: implement build
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
AppText('Low', fontSize: 24,),
|
Padding(
|
||||||
|
padding: EdgeInsets.only(top:10),
|
||||||
Padding(
|
child: AppText(data.name)),
|
||||||
padding: EdgeInsets.all(10),
|
AppText(
|
||||||
child:
|
data.category,
|
||||||
Stack(
|
fontSize: 24,
|
||||||
children: [
|
),
|
||||||
Container(
|
Padding(
|
||||||
decoration: BoxDecoration(gradient: LinearGradient(colors: [Colors.grey[100],Colors.grey[400] ]),
|
padding: EdgeInsets.all(10),
|
||||||
borderRadius: BorderRadius.circular(10)
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
margin: EdgeInsets.only(bottom:10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: [Colors.grey[100], Colors.grey[400]]),
|
||||||
|
borderRadius: BorderRadius.circular(10)),
|
||||||
|
height: 15,
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
child: SizedBox(),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
top: 0,
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: data.colorName =='red' ? red : data.colorName =='orange' ? orange : data.colorName =='green' ? green : data.colorName == 'yellow' ? yellow : grey,
|
||||||
|
borderRadius: BorderRadius.circular(10)),
|
||||||
|
height: 15,
|
||||||
|
width: (MediaQuery.of(context).size.width * (double.parse(data.value) / 10)),
|
||||||
|
padding: EdgeInsets.all(15),
|
||||||
|
child: SizedBox(),
|
||||||
|
)),
|
||||||
|
Positioned(child: Container(
|
||||||
|
height: 0,
|
||||||
|
width:0,
|
||||||
|
decoration: ShapeDecoration(
|
||||||
|
color:data.colorName =='red' ? Colors.redAccent : data.colorName =='orange' ? Colors.orangeAccent : data.colorName =='green' ? Colors.greenAccent : data.colorName == 'yellow' ? Colors.yellowAccent : Colors.grey,
|
||||||
|
shape: MessageBorder(),
|
||||||
|
|
||||||
|
)),top:25, left: (MediaQuery.of(context).size.width * (double.parse(data.value) / 10)),)
|
||||||
|
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(top:10),
|
||||||
|
child: data.isValuesReversed == false ? Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
AppText(
|
||||||
|
data.categoriesNames.category1,
|
||||||
|
fontSize: 12,
|
||||||
|
color: data.categoriesNames.category1== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category1== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category1== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category1== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black
|
||||||
|
),
|
||||||
|
AppText(
|
||||||
|
data.categoriesNames.category2,
|
||||||
|
fontSize: 12,
|
||||||
|
color: data.categoriesNames.category2== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category2== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category2== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category2== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black
|
||||||
|
|
||||||
|
),
|
||||||
|
AppText(
|
||||||
|
data.categoriesNames.category3,
|
||||||
|
fontSize: 12,
|
||||||
|
color: data.categoriesNames.category3== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category3== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category3== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category3== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black
|
||||||
|
|
||||||
|
),
|
||||||
|
AppText(
|
||||||
|
data.categoriesNames.category4,
|
||||||
|
fontSize: 12,
|
||||||
|
color: data.categoriesNames.category4== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category4== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category4== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category4== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black
|
||||||
|
|
||||||
|
),
|
||||||
|
AppText(
|
||||||
|
data.categoriesNames.category5,
|
||||||
|
fontSize: 12,
|
||||||
|
color: data.categoriesNames.category5== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category5== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category5== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category5== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black
|
||||||
|
|
||||||
|
),
|
||||||
|
],
|
||||||
|
) : Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
AppText(
|
||||||
|
data.categoriesNames.category5,
|
||||||
|
fontSize: 12,
|
||||||
|
color: data.categoriesNames.category5== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category5== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category5== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category5== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black
|
||||||
|
),
|
||||||
|
AppText(
|
||||||
|
data.categoriesNames.category4,
|
||||||
|
fontSize: 12,
|
||||||
|
color: data.categoriesNames.category4== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category4== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category4== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category4== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black
|
||||||
|
|
||||||
|
),
|
||||||
|
AppText(
|
||||||
|
data.categoriesNames.category3,
|
||||||
|
fontSize: 12,
|
||||||
|
color: data.categoriesNames.category3== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category3== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category3== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category3== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black
|
||||||
|
|
||||||
|
),
|
||||||
|
AppText(
|
||||||
|
data.categoriesNames.category2,
|
||||||
|
fontSize: 12,
|
||||||
|
color: data.categoriesNames.category2== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category2== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category2== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category2== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black
|
||||||
|
|
||||||
),
|
),
|
||||||
height: 15, width: MediaQuery.of(context).size.width,
|
AppText(
|
||||||
child:SizedBox(),
|
data.categoriesNames.category1,
|
||||||
),
|
fontSize: 12,
|
||||||
Positioned(
|
color: data.categoriesNames.category1== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category1== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category1== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category1== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black
|
||||||
top:0,
|
|
||||||
child: Container(
|
),
|
||||||
decoration: BoxDecoration(gradient: color,
|
],
|
||||||
borderRadius: BorderRadius.circular(10)
|
)),
|
||||||
),
|
Padding(
|
||||||
height: 15,
|
padding: EdgeInsets.all(15),
|
||||||
width: MediaQuery.of(context).size.width * width,
|
child:Divider())
|
||||||
padding: EdgeInsets.all(10),
|
],
|
||||||
child:SizedBox(),
|
);
|
||||||
|
|
||||||
)),
|
|
||||||
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
AppText('Low', fontSize: 12,),
|
|
||||||
AppText('Moderate', fontSize: 12,),
|
|
||||||
AppText('High', fontSize: 12,),
|
|
||||||
AppText('Very High', fontSize: 12,),
|
|
||||||
AppText('Extreme', fontSize: 12,),
|
|
||||||
],)
|
|
||||||
],);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
class MessageBorder extends ShapeBorder {
|
||||||
|
final bool usePadding;
|
||||||
|
|
||||||
|
MessageBorder({this.usePadding = true});
|
||||||
|
|
||||||
|
@override
|
||||||
|
EdgeInsetsGeometry get dimensions => EdgeInsets.only(bottom: usePadding? 0 : 0);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Path getInnerPath(Rect rect, {TextDirection textDirection}) => null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Path getOuterPath(Rect rect, {TextDirection textDirection}) {
|
||||||
|
rect = Rect.fromPoints(rect.bottomRight, rect.bottomLeft - Offset(0, 0));
|
||||||
|
return Path()
|
||||||
|
..addRRect(RRect.fromRectAndRadius(rect, Radius.circular(rect.height / 2)))
|
||||||
|
..moveTo(rect.topCenter.dx - 10, rect.topCenter.dy)
|
||||||
|
..relativeLineTo(10, -10)
|
||||||
|
..relativeLineTo(10,10)
|
||||||
|
..close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void paint(Canvas canvas, Rect rect, {TextDirection textDirection}) {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
ShapeBorder scale(double t) => this;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue