From 0e2411df950be9c0f4979817dad9c923e58d7234 Mon Sep 17 00:00:00 2001 From: hab Date: Mon, 29 Jan 2024 09:10:10 +0200 Subject: [PATCH] optimize imports --- lib/app/app.dart | 8 +--- lib/app/bloc/bloc.dart | 3 ++ lib/app/widgets/widgets.dart | 3 ++ lib/core/common/common.dart | 5 +++ .../screens/daily_forecast_screen.dart | 5 +-- .../widgets/daily_forecast_widget.dart | 7 +--- .../screens/widgets/daily_widget.dart | 38 +------------------ .../screens/widgets/date_widget.dart | 30 +++++++++++++++ .../screens/widgets/widgets.dart | 13 +++++++ lib/features/home/screens/home_screen.dart | 3 +- .../screens/hourly_forecast_screen.dart | 2 +- .../screens/widgets/custom_app_bar.dart | 10 +---- .../screens/widgets/day_and_night_widget.dart | 4 +- .../screens/widgets/forecast_info_widget.dart | 7 +--- .../widgets/hourly_forecast_details.dart | 6 +-- .../widgets/hourly_forecast_widget.dart | 12 +----- .../hourly_forecast/screens/widgets/news.dart | 4 +- .../screens/widgets/news_widget.dart | 11 +----- .../screens/widgets/widgets.dart | 26 +++++++++++++ 19 files changed, 95 insertions(+), 102 deletions(-) create mode 100644 lib/app/bloc/bloc.dart create mode 100644 lib/app/widgets/widgets.dart create mode 100644 lib/core/common/common.dart create mode 100644 lib/features/daily_forecast/screens/widgets/date_widget.dart create mode 100644 lib/features/daily_forecast/screens/widgets/widgets.dart create mode 100644 lib/features/hourly_forecast/screens/widgets/widgets.dart diff --git a/lib/app/app.dart b/lib/app/app.dart index 54e4690..764b574 100644 --- a/lib/app/app.dart +++ b/lib/app/app.dart @@ -1,8 +1,5 @@ -import 'package:clima/app/bloc/network/network_cubit.dart'; -import 'package:clima/app/bloc/theme/theme_cubit.dart'; -import 'package:clima/app/widgets/location_service_disabled.dart'; -import 'package:clima/app/widgets/permission_denied_widget.dart'; -import 'package:clima/app/widgets/waiting_permission_widget.dart'; +import 'package:clima/app/bloc/bloc.dart'; +import 'package:clima/app/widgets/widgets.dart'; import 'package:clima/core/utils/utils.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -10,7 +7,6 @@ import 'package:lottie/lottie.dart'; import '../core/common/loading_widget.dart'; import '../features/landing_page/landing_screen.dart'; -import 'bloc/location/location_bloc.dart'; class MyApp extends StatelessWidget { const MyApp({super.key}); diff --git a/lib/app/bloc/bloc.dart b/lib/app/bloc/bloc.dart new file mode 100644 index 0000000..0f5b012 --- /dev/null +++ b/lib/app/bloc/bloc.dart @@ -0,0 +1,3 @@ +export 'location/location_bloc.dart'; +export 'network/network_cubit.dart'; +export 'theme/theme_cubit.dart'; diff --git a/lib/app/widgets/widgets.dart b/lib/app/widgets/widgets.dart new file mode 100644 index 0000000..0e88639 --- /dev/null +++ b/lib/app/widgets/widgets.dart @@ -0,0 +1,3 @@ +export 'location_service_disabled.dart'; +export 'permission_denied_widget.dart'; +export 'waiting_permission_widget.dart'; diff --git a/lib/core/common/common.dart b/lib/core/common/common.dart new file mode 100644 index 0000000..9d376f5 --- /dev/null +++ b/lib/core/common/common.dart @@ -0,0 +1,5 @@ +export 'failure_widget.dart'; +export 'loading_widget.dart'; +export 'primary_button.dart'; +export 'temperature_text.dart'; +export 'weather_image.dart'; diff --git a/lib/features/daily_forecast/screens/daily_forecast_screen.dart b/lib/features/daily_forecast/screens/daily_forecast_screen.dart index b4fdd14..8d6c454 100644 --- a/lib/features/daily_forecast/screens/daily_forecast_screen.dart +++ b/lib/features/daily_forecast/screens/daily_forecast_screen.dart @@ -1,7 +1,6 @@ -import 'package:clima/core/common/failure_widget.dart'; -import 'package:clima/core/common/loading_widget.dart'; +import 'package:clima/core/common/common.dart'; import 'package:clima/features/daily_forecast/cubit/daily_forecast_cubit.dart'; -import 'package:clima/features/daily_forecast/screens/widgets/daily_forecast_widget.dart'; +import 'package:clima/features/daily_forecast/screens/widgets/widgets.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; diff --git a/lib/features/daily_forecast/screens/widgets/daily_forecast_widget.dart b/lib/features/daily_forecast/screens/widgets/daily_forecast_widget.dart index f30afac..0dc5c09 100644 --- a/lib/features/daily_forecast/screens/widgets/daily_forecast_widget.dart +++ b/lib/features/daily_forecast/screens/widgets/daily_forecast_widget.dart @@ -1,9 +1,4 @@ -import 'package:clima/core/utils/utils.dart'; -import 'package:clima/features/daily_forecast/data/models/daily_weather_model.dart'; -import 'package:flutter/material.dart'; - -import '../../../../core/animations/fade_slide_animation.dart'; -import 'daily_widget.dart'; +part of 'widgets.dart'; class DailyForecastWidget extends StatefulWidget { const DailyForecastWidget({ diff --git a/lib/features/daily_forecast/screens/widgets/daily_widget.dart b/lib/features/daily_forecast/screens/widgets/daily_widget.dart index 476fc93..952ded9 100644 --- a/lib/features/daily_forecast/screens/widgets/daily_widget.dart +++ b/lib/features/daily_forecast/screens/widgets/daily_widget.dart @@ -1,11 +1,4 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:lottie/lottie.dart'; - -import '../../../../core/common/temperature_text.dart'; -import '../../../../core/helper/date_helper.dart'; -import '../../../../core/utils/utils.dart'; -import '../../data/models/daily_weather_model.dart'; +part of 'widgets.dart'; class DailyWidget extends StatelessWidget { const DailyWidget({ @@ -83,32 +76,3 @@ class DailyWidget extends StatelessWidget { ); } } - -class DataWidget extends StatelessWidget { - const DataWidget({ - super.key, - required this.apparentTemperature, - required this.icon, - }); - - final String apparentTemperature; - final String icon; - - @override - Widget build(BuildContext context) { - return Row( - children: [ - SvgPicture.asset( - icon, - width: AppDimensions.width! * 0.07, - fit: BoxFit.cover, - ), - const SizedBox(width: 5), - Text( - apparentTemperature, - style: AppTypography.medium12(), - ), - ], - ); - } -} diff --git a/lib/features/daily_forecast/screens/widgets/date_widget.dart b/lib/features/daily_forecast/screens/widgets/date_widget.dart new file mode 100644 index 0000000..f7cee2e --- /dev/null +++ b/lib/features/daily_forecast/screens/widgets/date_widget.dart @@ -0,0 +1,30 @@ +part of 'widgets.dart'; + +class DataWidget extends StatelessWidget { + const DataWidget({ + super.key, + required this.apparentTemperature, + required this.icon, + }); + + final String apparentTemperature; + final String icon; + + @override + Widget build(BuildContext context) { + return Row( + children: [ + SvgPicture.asset( + icon, + width: AppDimensions.width! * 0.07, + fit: BoxFit.cover, + ), + const SizedBox(width: 5), + Text( + apparentTemperature, + style: AppTypography.medium12(), + ), + ], + ); + } +} diff --git a/lib/features/daily_forecast/screens/widgets/widgets.dart b/lib/features/daily_forecast/screens/widgets/widgets.dart new file mode 100644 index 0000000..2012efd --- /dev/null +++ b/lib/features/daily_forecast/screens/widgets/widgets.dart @@ -0,0 +1,13 @@ +import 'package:clima/core/utils/utils.dart'; +import 'package:clima/features/daily_forecast/data/models/daily_weather_model.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:lottie/lottie.dart'; + +import '../../../../core/animations/fade_slide_animation.dart'; +import '../../../../core/common/temperature_text.dart'; +import '../../../../core/helper/date_helper.dart'; + +part 'daily_forecast_widget.dart'; +part 'daily_widget.dart'; +part 'date_widget.dart'; diff --git a/lib/features/home/screens/home_screen.dart b/lib/features/home/screens/home_screen.dart index e5a1f92..ff2a98d 100644 --- a/lib/features/home/screens/home_screen.dart +++ b/lib/features/home/screens/home_screen.dart @@ -1,6 +1,5 @@ import 'package:clima/app/bloc/theme/theme_cubit.dart'; -import 'package:clima/core/common/failure_widget.dart'; -import 'package:clima/core/common/loading_widget.dart'; +import 'package:clima/core/common/common.dart'; import 'package:clima/core/services/notification_service.dart'; import 'package:clima/features/home/cubit/home_cubit.dart'; import 'package:clima/features/home/screens/widgets/widgets.dart'; diff --git a/lib/features/hourly_forecast/screens/hourly_forecast_screen.dart b/lib/features/hourly_forecast/screens/hourly_forecast_screen.dart index 66c29c3..daa216f 100644 --- a/lib/features/hourly_forecast/screens/hourly_forecast_screen.dart +++ b/lib/features/hourly_forecast/screens/hourly_forecast_screen.dart @@ -1,6 +1,6 @@ import 'package:clima/core/common/failure_widget.dart'; import 'package:clima/core/common/loading_widget.dart'; -import 'package:clima/features/hourly_forecast/screens/widgets/hourly_forecast_widget.dart'; +import 'package:clima/features/hourly_forecast/screens/widgets/widgets.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; diff --git a/lib/features/hourly_forecast/screens/widgets/custom_app_bar.dart b/lib/features/hourly_forecast/screens/widgets/custom_app_bar.dart index c9eac30..2755d9e 100644 --- a/lib/features/hourly_forecast/screens/widgets/custom_app_bar.dart +++ b/lib/features/hourly_forecast/screens/widgets/custom_app_bar.dart @@ -1,12 +1,4 @@ -import 'package:clima/features/hourly_forecast/data/models/weather_daily_model.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; - -import '../../../../core/common/temperature_text.dart'; -import '../../../../core/common/weather_image.dart'; -import '../../../../core/helper/location_helper.dart'; -import '../../../../core/utils/utils.dart'; -import '../../../home/cubit/home_cubit.dart'; +part of 'widgets.dart'; class CustomAppBar extends StatelessWidget { const CustomAppBar( diff --git a/lib/features/hourly_forecast/screens/widgets/day_and_night_widget.dart b/lib/features/hourly_forecast/screens/widgets/day_and_night_widget.dart index edb10db..f8942f0 100644 --- a/lib/features/hourly_forecast/screens/widgets/day_and_night_widget.dart +++ b/lib/features/hourly_forecast/screens/widgets/day_and_night_widget.dart @@ -1,6 +1,4 @@ -import 'package:flutter/material.dart'; - -import '../../../../core/utils/utils.dart'; +part of 'widgets.dart'; class DayAndNight extends StatelessWidget { const DayAndNight({ diff --git a/lib/features/hourly_forecast/screens/widgets/forecast_info_widget.dart b/lib/features/hourly_forecast/screens/widgets/forecast_info_widget.dart index 2f957f8..7dc69b4 100644 --- a/lib/features/hourly_forecast/screens/widgets/forecast_info_widget.dart +++ b/lib/features/hourly_forecast/screens/widgets/forecast_info_widget.dart @@ -1,9 +1,4 @@ -import 'package:clima/core/utils/utils.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; - -import '../../data/models/forecast_info_model.dart'; -import '../../data/models/weather_daily_model.dart'; +part of 'widgets.dart'; class ForecastInfoWidget extends StatelessWidget { const ForecastInfoWidget({ diff --git a/lib/features/hourly_forecast/screens/widgets/hourly_forecast_details.dart b/lib/features/hourly_forecast/screens/widgets/hourly_forecast_details.dart index 1dd5fde..9ebf5bd 100644 --- a/lib/features/hourly_forecast/screens/widgets/hourly_forecast_details.dart +++ b/lib/features/hourly_forecast/screens/widgets/hourly_forecast_details.dart @@ -1,8 +1,4 @@ -import 'package:clima/core/utils/utils.dart'; -import 'package:flutter/material.dart'; -import 'package:lottie/lottie.dart'; - -import '../../data/models/weather_hourly_model.dart'; +part of 'widgets.dart'; class HourlyForecastDetails extends StatelessWidget { const HourlyForecastDetails({ diff --git a/lib/features/hourly_forecast/screens/widgets/hourly_forecast_widget.dart b/lib/features/hourly_forecast/screens/widgets/hourly_forecast_widget.dart index f6092bc..1099e07 100644 --- a/lib/features/hourly_forecast/screens/widgets/hourly_forecast_widget.dart +++ b/lib/features/hourly_forecast/screens/widgets/hourly_forecast_widget.dart @@ -1,14 +1,4 @@ -import 'package:clima/core/utils/utils.dart'; -import 'package:flutter/material.dart'; - -import '../../data/models/weather_daily_model.dart'; -import '../../data/models/weather_hourly_model.dart'; -import '../../data/models/weather_news_model.dart'; -import 'custom_app_bar.dart'; -import 'day_and_night_widget.dart'; -import 'forecast_info_widget.dart'; -import 'hourly_forecast_details.dart'; -import 'news_widget.dart'; +part of 'widgets.dart'; class HourlyForecastWidget extends StatelessWidget { const HourlyForecastWidget( diff --git a/lib/features/hourly_forecast/screens/widgets/news.dart b/lib/features/hourly_forecast/screens/widgets/news.dart index 5cd0ffb..4cde0e4 100644 --- a/lib/features/hourly_forecast/screens/widgets/news.dart +++ b/lib/features/hourly_forecast/screens/widgets/news.dart @@ -1,6 +1,4 @@ -import 'package:flutter/material.dart'; - -import '../../../../core/utils/app_typography.dart'; +part of 'widgets.dart'; class News extends StatelessWidget { const News({ diff --git a/lib/features/hourly_forecast/screens/widgets/news_widget.dart b/lib/features/hourly_forecast/screens/widgets/news_widget.dart index 488a464..3e81fcc 100644 --- a/lib/features/hourly_forecast/screens/widgets/news_widget.dart +++ b/lib/features/hourly_forecast/screens/widgets/news_widget.dart @@ -1,13 +1,4 @@ -import 'dart:async'; - -import 'package:clima/features/hourly_forecast/data/models/weather_news_model.dart'; -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:url_launcher/url_launcher.dart'; - -import '../../../../core/utils/utils.dart'; -import '../../data/models/weather_daily_model.dart'; -import 'news.dart'; +part of 'widgets.dart'; class NewsWidget extends StatefulWidget { const NewsWidget( diff --git a/lib/features/hourly_forecast/screens/widgets/widgets.dart b/lib/features/hourly_forecast/screens/widgets/widgets.dart new file mode 100644 index 0000000..7bb3ddc --- /dev/null +++ b/lib/features/hourly_forecast/screens/widgets/widgets.dart @@ -0,0 +1,26 @@ +import 'dart:async'; + +import 'package:clima/features/hourly_forecast/data/models/weather_daily_model.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:intl/intl.dart'; +import 'package:lottie/lottie.dart'; +import 'package:url_launcher/url_launcher.dart'; + +import '../../../../core/common/temperature_text.dart'; +import '../../../../core/common/weather_image.dart'; +import '../../../../core/helper/location_helper.dart'; +import '../../../../core/utils/utils.dart'; +import '../../../home/cubit/home_cubit.dart'; +import '../../data/models/forecast_info_model.dart'; +import '../../data/models/weather_hourly_model.dart'; +import '../../data/models/weather_news_model.dart'; + +part 'custom_app_bar.dart'; +part 'day_and_night_widget.dart'; +part 'forecast_info_widget.dart'; +part 'hourly_forecast_details.dart'; +part 'hourly_forecast_widget.dart'; +part 'news.dart'; +part 'news_widget.dart';