Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonavichus committed Apr 5, 2023
1 parent 4d5936e commit 770216d
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 48 deletions.
3 changes: 3 additions & 0 deletions lib/app/modules/card_weather.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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!,
Expand Down
20 changes: 15 additions & 5 deletions lib/app/modules/weather.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
Expand Down Expand Up @@ -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(
Expand All @@ -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()],
),
),
),
Expand All @@ -113,23 +123,23 @@ 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![
locationController.dayOfNow.value],
image: 'assets/images/sunrise.png',
),
),
const SizedBox(width: 10),
Flexible(
Expanded(
child: SunsetSunrise(
title: 'sunset'.tr,
time: locationController.daily
Expand All @@ -141,7 +151,7 @@ class _WeatherPageState extends State<WeatherPage> {
),
)
: const MyShimmer(
hight: 80,
hight: 90,
edgeInsetsMargin: EdgeInsets.only(bottom: 15),
),
),
Expand Down
15 changes: 11 additions & 4 deletions lib/app/modules/weather_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -115,6 +117,7 @@ class _WeatherCardPageState extends State<WeatherCardPage> {
itemBuilder: (ctx, i) => GestureDetector(
onTap: () {
timeNow = i;
dayNow = (i / 24).floor();
setState(() {});
},
child: Container(
Expand All @@ -135,29 +138,33 @@ 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()],
),
),
),
),
),
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],
Expand Down
12 changes: 11 additions & 1 deletion lib/app/widgets/card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
),
],
Expand Down
18 changes: 12 additions & 6 deletions lib/app/widgets/status.dart
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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:
Expand Down
10 changes: 7 additions & 3 deletions lib/app/widgets/sunset_sunrise.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class _SunsetSunriseState extends State<SunsetSunrise> {
@override
Widget build(BuildContext context) {
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Column(
Expand All @@ -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(
Expand All @@ -41,9 +43,11 @@ class _SunsetSunriseState extends State<SunsetSunrise> {
],
),
),
Image.asset(
widget.image,
scale: 10,
Expanded(
child: Image.asset(
widget.image,
scale: 10,
),
),
],
);
Expand Down
7 changes: 6 additions & 1 deletion lib/app/widgets/weather_hourly.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(
Expand Down
7 changes: 6 additions & 1 deletion lib/app/widgets/weather_now.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
),
Expand Down
2 changes: 0 additions & 2 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"))
Expand Down
24 changes: 0 additions & 24 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 770216d

Please sign in to comment.