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/contactus/findus_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/weather/weather_view_model.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/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/slider/slider.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/material.dart';
|
||||
import 'package:flutter_xlider/flutter_xlider.dart';
|
||||
import 'package:giffy_dialog/giffy_dialog.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:maps_launcher/maps_launcher.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class HealthWeatherIndicator extends StatefulWidget {
|
||||
|
||||
|
||||
@override
|
||||
_HospitalsPageState createState() => _HospitalsPageState();
|
||||
}
|
||||
|
||||
|
||||
class _HospitalsPageState extends State<HealthWeatherIndicator> {
|
||||
LinearGradient gradient = LinearGradient(
|
||||
colors: <Color> [
|
||||
Colors.red,
|
||||
Colors.orange,
|
||||
Colors.yellow,
|
||||
Colors.green,
|
||||
Colors.blue,
|
||||
Colors.blue[900],
|
||||
Colors.purple
|
||||
]
|
||||
);
|
||||
var data;
|
||||
LocationUtils locationUtils;
|
||||
@override
|
||||
void initState() {
|
||||
locationUtils =
|
||||
new LocationUtils(isShowConfirmDialog: true, context: context);
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) => locationUtils.getCurrentLocation());
|
||||
|
||||
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 ])),
|
||||
])
|
||||
),
|
||||
ProjectViewModel projectViewModel = Provider.of(context);
|
||||
return BaseView<WeatherViewModel>(
|
||||
onModelReady: (model) => model.getWeatherData(),
|
||||
builder: (_, mode, widget) => AppScaffold(
|
||||
isShowDecPage: false,
|
||||
appBarTitle: TranslationBase.of(context).healthWeatherIndicators,
|
||||
isShowAppBar: true,
|
||||
baseViewModel: mode,
|
||||
body: mode.weatherIndicatorData.length>0 ? SingleChildScrollView(
|
||||
child: Column(children: [
|
||||
Padding(padding: EdgeInsets.all(15), child:AppText( projectViewModel.isArabic ? mode.weatherIndicatorData[0].cityNameN : mode.weatherIndicatorData[0].cityName, fontSize: 24, fontWeight: FontWeight.bold,)),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Column(children:
|
||||
mode.weatherIndicatorData
|
||||
.map((data) {
|
||||
return WeatherSlider(
|
||||
data);
|
||||
}).toList()
|
||||
|
||||
))])) : Container(child:AppText('Loading...'))),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class WeatherSlider extends StatelessWidget{
|
||||
final width;
|
||||
final LinearGradient color;
|
||||
WeatherSlider(this.width, this.color);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: implement build
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
AppText('Low', fontSize: 24,),
|
||||
|
||||
Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child:
|
||||
Stack(
|
||||
children: [
|
||||
Container(
|
||||
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: 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{
|
||||
final width;
|
||||
final LinearGradient color;
|
||||
WeatherSlider(this.width, this.color);
|
||||
|
||||
class WeatherSlider extends StatelessWidget {
|
||||
// final width;
|
||||
// final LinearGradient color;
|
||||
final GetCityInfoList data;
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: implement build
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AppText('Low', fontSize: 24,),
|
||||
|
||||
Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child:
|
||||
Stack(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(gradient: LinearGradient(colors: [Colors.grey[100],Colors.grey[400] ]),
|
||||
borderRadius: BorderRadius.circular(10)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top:10),
|
||||
child: AppText(data.name)),
|
||||
AppText(
|
||||
data.category,
|
||||
fontSize: 24,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(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
|
||||
|
||||
),
|
||||
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
|
||||
|
||||
),
|
||||
height: 15, width: MediaQuery.of(context).size.width,
|
||||
child:SizedBox(),
|
||||
),
|
||||
Positioned(
|
||||
top:0,
|
||||
child: Container(
|
||||
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,),
|
||||
],)
|
||||
],);
|
||||
],
|
||||
)),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child:Divider())
|
||||
],
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
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