This commit is contained in:
Yoshi 2023-04-05 14:23:06 +03:00
parent 4d5936e49c
commit 770216dd45
11 changed files with 71 additions and 48 deletions

View file

@ -123,6 +123,9 @@ class _CardWeatherState extends State<CardWeather> {
transition: Transition.downToUp),
child: CardDescWeather(
time: weatherCardList.time!,
timeDaily: weatherCardList.timeDaily!,
timeDay: weatherCardList.sunrise!,
timeNight: weatherCardList.sunset!,
weather: weatherCardList.weathercode!,
degree: weatherCardList.temperature2M!,
district: weatherCardList.district!,

View file

@ -44,6 +44,10 @@ class _WeatherPageState extends State<WeatherPage> {
.weathercode![locationController.hourOfDay.value],
degree: locationController.hourly
.temperature2M![locationController.hourOfDay.value],
timeDay: locationController
.daily.sunrise![locationController.dayOfNow.value],
timeNight: locationController
.daily.sunset![locationController.dayOfNow.value],
)
: const MyShimmer(hight: 350),
),
@ -77,6 +81,8 @@ class _WeatherPageState extends State<WeatherPage> {
itemBuilder: (ctx, i) => GestureDetector(
onTap: () {
locationController.hourOfDay.value = i;
locationController.dayOfNow.value =
(i / 24).floor();
setState(() {});
},
child: Container(
@ -99,6 +105,10 @@ class _WeatherPageState extends State<WeatherPage> {
locationController.hourly.weathercode![i],
degree:
locationController.hourly.temperature2M![i],
timeDay: locationController
.daily.sunrise![(i / 24).floor()],
timeNight: locationController
.daily.sunset![(i / 24).floor()],
),
),
),
@ -113,14 +123,15 @@ class _WeatherPageState extends State<WeatherPage> {
() => locationController.isLoading.isFalse
? Container(
margin: const EdgeInsets.only(bottom: 15),
padding: const EdgeInsets.fromLTRB(10, 15, 20, 15),
padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 5),
decoration: BoxDecoration(
color: context.theme.colorScheme.primaryContainer,
borderRadius:
const BorderRadius.all(Radius.circular(20))),
child: Row(
children: [
Flexible(
Expanded(
child: SunsetSunrise(
title: 'sunrise'.tr,
time: locationController.daily.sunrise![
@ -128,8 +139,7 @@ class _WeatherPageState extends State<WeatherPage> {
image: 'assets/images/sunrise.png',
),
),
const SizedBox(width: 10),
Flexible(
Expanded(
child: SunsetSunrise(
title: 'sunset'.tr,
time: locationController.daily
@ -141,7 +151,7 @@ class _WeatherPageState extends State<WeatherPage> {
),
)
: const MyShimmer(
hight: 80,
hight: 90,
edgeInsetsMargin: EdgeInsets.only(bottom: 15),
),
),

View file

@ -87,6 +87,8 @@ class _WeatherCardPageState extends State<WeatherCardPage> {
time: widget.weatherCard.time![timeNow],
weather: widget.weatherCard.weathercode![timeNow],
degree: widget.weatherCard.temperature2M![timeNow],
timeDay: widget.weatherCard.sunrise![dayNow],
timeNight: widget.weatherCard.sunset![dayNow],
),
Container(
height: 130,
@ -115,6 +117,7 @@ class _WeatherCardPageState extends State<WeatherCardPage> {
itemBuilder: (ctx, i) => GestureDetector(
onTap: () {
timeNow = i;
dayNow = (i / 24).floor();
setState(() {});
},
child: Container(
@ -135,6 +138,10 @@ class _WeatherCardPageState extends State<WeatherCardPage> {
time: widget.weatherCard.time![i],
weather: widget.weatherCard.weathercode![i],
degree: widget.weatherCard.temperature2M![i],
timeDay:
widget.weatherCard.sunrise![(i / 24).floor()],
timeNight:
widget.weatherCard.sunset![(i / 24).floor()],
),
),
),
@ -142,22 +149,22 @@ class _WeatherCardPageState extends State<WeatherCardPage> {
),
Container(
margin: const EdgeInsets.only(bottom: 15),
padding: const EdgeInsets.fromLTRB(10, 15, 20, 15),
padding:
const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
decoration: BoxDecoration(
color: context.theme.colorScheme.primaryContainer,
borderRadius:
const BorderRadius.all(Radius.circular(20))),
child: Row(
children: [
Flexible(
Expanded(
child: SunsetSunrise(
title: 'sunrise'.tr,
time: widget.weatherCard.sunrise![dayNow],
image: 'assets/images/sunrise.png',
),
),
const SizedBox(width: 10),
Flexible(
Expanded(
child: SunsetSunrise(
title: 'sunset'.tr,
time: widget.weatherCard.sunset![dayNow],

View file

@ -15,8 +15,14 @@ class CardDescWeather extends StatefulWidget {
required this.district,
required this.city,
required this.timezone,
required this.timeDay,
required this.timeNight,
required this.timeDaily,
});
final List<String> time;
final List<String> timeDay;
final List<String> timeNight;
final List<DateTime> timeDaily;
final String district;
final String city;
final List<int> weather;
@ -107,7 +113,11 @@ class _CardDescWeatherState extends State<CardDescWeather> {
widget.weather[
locationController.getTime(widget.time, widget.timezone)],
widget.time[
locationController.getTime(widget.time, widget.timezone)]),
locationController.getTime(widget.time, widget.timezone)],
widget.timeDay[locationController.getDay(
widget.timeDaily, widget.timezone)],
widget.timeNight[locationController.getDay(
widget.timeDaily, widget.timezone)]),
scale: 6.5,
),
],

View file

@ -1,13 +1,16 @@
import 'package:get/get.dart';
class Status {
String getImageNow(int weather, String time) {
String getImageNow(
int weather, String time, String timeDay, String timeNight) {
final currentTime = DateTime.parse(time);
final day = DateTime.parse(timeDay);
final night = DateTime.parse(timeNight);
final dayTime =
DateTime(currentTime.year, currentTime.month, currentTime.day, 6, 00);
DateTime(day.year, day.month, day.day, day.hour, day.minute);
final nightTime =
DateTime(currentTime.year, currentTime.month, currentTime.day, 19, 00);
DateTime(night.year, night.month, night.day, night.hour, night.minute);
switch (weather) {
case 0:
@ -61,13 +64,16 @@ class Status {
}
}
String getImageToday(String time, int weather) {
String getImageToday(
String time, int weather, String timeDay, String timeNight) {
final currentTime = DateTime.parse(time);
final day = DateTime.parse(timeDay);
final night = DateTime.parse(timeNight);
final dayTime =
DateTime(currentTime.year, currentTime.month, currentTime.day, 6, 00);
DateTime(day.year, day.month, day.day, day.hour, day.minute);
final nightTime =
DateTime(currentTime.year, currentTime.month, currentTime.day, 19, 00);
DateTime(night.year, night.month, night.day, night.hour, night.minute);
switch (weather) {
case 0:

View file

@ -22,6 +22,7 @@ class _SunsetSunriseState extends State<SunsetSunrise> {
@override
Widget build(BuildContext context) {
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Column(
@ -31,6 +32,7 @@ class _SunsetSunriseState extends State<SunsetSunrise> {
widget.title,
style: context.theme.textTheme.titleSmall,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
),
const SizedBox(height: 2),
Text(
@ -41,9 +43,11 @@ class _SunsetSunriseState extends State<SunsetSunrise> {
],
),
),
Image.asset(
widget.image,
scale: 10,
Expanded(
child: Image.asset(
widget.image,
scale: 10,
),
),
],
);

View file

@ -10,8 +10,12 @@ class WeatherHourly extends StatefulWidget {
required this.time,
required this.weather,
required this.degree,
required this.timeDay,
required this.timeNight,
});
final String time;
final String timeDay;
final String timeNight;
final int weather;
final double degree;
@ -46,7 +50,8 @@ class _WeatherHourlyState extends State<WeatherHourly> {
],
),
Image.asset(
status.getImageToday(widget.time, widget.weather),
status.getImageToday(
widget.time, widget.weather, widget.timeDay, widget.timeNight),
scale: 3,
),
Text(

View file

@ -10,8 +10,12 @@ class WeatherNow extends StatefulWidget {
required this.weather,
required this.degree,
required this.time,
required this.timeDay,
required this.timeNight,
});
final String time;
final String timeDay;
final String timeNight;
final int weather;
final double degree;
@ -30,7 +34,8 @@ class _WeatherNowState extends State<WeatherNow> {
children: [
const SizedBox(height: 15),
Image(
image: AssetImage(status.getImageNow(widget.weather, widget.time)),
image: AssetImage(status.getImageNow(
widget.weather, widget.time, widget.timeDay, widget.timeNight)),
fit: BoxFit.fill,
height: 200,
),

View file

@ -6,7 +6,6 @@ import FlutterMacOS
import Foundation
import connectivity_plus
import flutter_local_notifications
import geolocator_apple
import isar_flutter_libs
import package_info_plus
@ -15,7 +14,6 @@ import url_launcher_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
IsarFlutterLibsPlugin.register(with: registry.registrar(forPlugin: "IsarFlutterLibsPlugin"))
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))

View file

@ -310,30 +310,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.1"
flutter_local_notifications:
dependency: "direct main"
description:
name: flutter_local_notifications
sha256: "293995f94e120c8afce768981bd1fa9c5d6de67c547568e3b42ae2defdcbb4a0"
url: "https://pub.dev"
source: hosted
version: "13.0.0"
flutter_local_notifications_linux:
dependency: transitive
description:
name: flutter_local_notifications_linux
sha256: ccb08b93703aeedb58856e5637450bf3ffec899adb66dc325630b68994734b89
url: "https://pub.dev"
source: hosted
version: "3.0.0+1"
flutter_local_notifications_platform_interface:
dependency: transitive
description:
name: flutter_local_notifications_platform_interface
sha256: "5ec1feac5f7f7d9266759488bc5f76416152baba9aa1b26fe572246caa00d1ab"
url: "https://pub.dev"
source: hosted
version: "6.0.0"
flutter_localizations:
dependency: "direct main"
description: flutter

View file

@ -32,7 +32,6 @@ dependencies:
lat_lng_to_timezone: ^0.2.0
custom_navigation_bar: ^0.8.2
scrollable_positioned_list: ^0.3.5
flutter_local_notifications: ^13.0.0
internet_connection_checker: ^1.0.0+1
dev_dependencies: