From 8091fb99132242b3059effd6ec9ec4716236a187 Mon Sep 17 00:00:00 2001 From: hoogom88 Date: Tue, 4 Jun 2024 13:31:50 +0900 Subject: [PATCH 1/3] =?UTF-8?q?Feat:=20=ED=99=88=20=ED=99=94=EB=A9=B4=20?= =?UTF-8?q?=EC=A7=84=EC=9E=85=20=EC=8B=9C=20=ED=94=BC=EB=93=9C=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=B5=9C=EC=B4=88=20?= =?UTF-8?q?=ED=94=BC=EB=93=9C=2020=EA=B0=9C=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=20=ED=94=84=EB=A6=AC=20=EC=BA=90=EC=8B=B1=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/core/di/di_setup.dart | 2 ++ .../component/recommend_ootd_list_widget.dart | 23 ++++++++----------- lib/presentation/home/screen/home_screen.dart | 8 +++++++ .../view_model/home_screen_view_model.dart | 7 ++++++ 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/lib/core/di/di_setup.dart b/lib/core/di/di_setup.dart index 3a778569..30a51fe1 100644 --- a/lib/core/di/di_setup.dart +++ b/lib/core/di/di_setup.dart @@ -7,6 +7,7 @@ import 'package:weaco/core/di/user/user_di_setup.dart'; import 'package:weaco/core/di/weather/weather_di_setup.dart'; import 'package:weaco/domain/feed/use_case/get_my_page_feeds_use_case.dart'; import 'package:weaco/domain/feed/use_case/get_recommended_feeds_use_case.dart'; +import 'package:weaco/domain/feed/use_case/get_search_feeds_use_case.dart'; import 'package:weaco/domain/feed/use_case/remove_my_page_feed_use_case.dart'; import 'package:weaco/domain/user/repository/user_auth_repository.dart'; import 'package:weaco/domain/user/use_case/get_my_profile_use_case.dart'; @@ -61,6 +62,7 @@ void diSetup() { getDailyLocationWeatherUseCase: getIt(), getBackgroundImageListUseCase: getIt(), getRecommendedFeedsUseCase: getIt(), + getSearchFeedsUseCase: getIt(), ), ); diff --git a/lib/presentation/home/component/recommend_ootd_list_widget.dart b/lib/presentation/home/component/recommend_ootd_list_widget.dart index c66f21aa..abe511cd 100644 --- a/lib/presentation/home/component/recommend_ootd_list_widget.dart +++ b/lib/presentation/home/component/recommend_ootd_list_widget.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:collection/collection.dart'; import 'package:weaco/core/go_router/router_static.dart'; import 'package:weaco/domain/feed/model/feed.dart'; import 'package:weaco/domain/weather/model/daily_location_weather.dart'; @@ -40,21 +41,17 @@ class RecommendOotdListWidget extends StatelessWidget { ), ) : Expanded( - child: ListView.builder( + child: ListView( scrollDirection: Axis.horizontal, - itemCount: feedList.length, - itemBuilder: (context, index) { - return GestureDetector( - onTap: () => RouterStatic.pushToOotdDetail( + children: feedList.mapIndexed((index, element) => GestureDetector( + onTap: () => RouterStatic.pushToOotdDetail( context, - feed: feedList[index] - ), - child: RecommendOotdWidget( - feedList: feedList, - index: index, - ), - ); - }, + feed: element), + child: RecommendOotdWidget( + feedList: feedList, + index: index, + ), + )).toList() ), ), ], diff --git a/lib/presentation/home/screen/home_screen.dart b/lib/presentation/home/screen/home_screen.dart index 1ec19ca4..7b82802d 100644 --- a/lib/presentation/home/screen/home_screen.dart +++ b/lib/presentation/home/screen/home_screen.dart @@ -1,6 +1,8 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:weaco/core/util/reaction_util.dart'; +import 'package:weaco/domain/feed/model/feed.dart'; import 'package:weaco/presentation/common/style/image_path.dart'; import 'package:weaco/core/enum/weather_code.dart'; import 'package:weaco/presentation/common/enum/exception_alert.dart'; @@ -26,6 +28,12 @@ class _HomeScreenState extends State { Future.microtask( () async { await context.read().initHomeScreen(); + final tmp = context.read().precacheList; + if (mounted) { + for (Feed e in tmp) { + await precacheImage(CachedNetworkImageProvider(e.thumbnailImagePath), context); + }; + } }, ); } diff --git a/lib/presentation/home/view_model/home_screen_view_model.dart b/lib/presentation/home/view_model/home_screen_view_model.dart index fcb5ab3f..45615710 100644 --- a/lib/presentation/home/view_model/home_screen_view_model.dart +++ b/lib/presentation/home/view_model/home_screen_view_model.dart @@ -1,4 +1,6 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; +import 'package:weaco/domain/feed/use_case/get_search_feeds_use_case.dart'; import 'package:weaco/presentation/common/style/image_path.dart'; import 'package:weaco/core/enum/weather_code.dart'; import 'package:weaco/domain/feed/model/feed.dart'; @@ -26,16 +28,19 @@ class HomeScreenViewModel with ChangeNotifier { required this.getDailyLocationWeatherUseCase, required this.getBackgroundImageListUseCase, required this.getRecommendedFeedsUseCase, + required this.getSearchFeedsUseCase, }); final GetDailyLocationWeatherUseCase getDailyLocationWeatherUseCase; final GetBackgroundImageListUseCase getBackgroundImageListUseCase; final GetRecommendedFeedsUseCase getRecommendedFeedsUseCase; + final GetSearchFeedsUseCase getSearchFeedsUseCase; DailyLocationWeather? _dailyLocationWeather; Weather? _currentWeather; List _weatherByTimeList = []; List _feedList = []; + List _precacheList = []; HomeScreenStatus _status = HomeScreenStatus.idle; // 전일 대비 온도차 double? _temperatureGap; @@ -45,6 +50,7 @@ class HomeScreenViewModel with ChangeNotifier { Weather? get currentWeather => _currentWeather; double? get temperatureGap => _temperatureGap ?? 0; List get feedList => _feedList; + List get precacheList => _precacheList; HomeScreenStatus get status => _status; String get backgroundImagePath => _weatherBackgroundImage ?? ImagePath.homeBackgroundSunny; @@ -62,6 +68,7 @@ class HomeScreenViewModel with ChangeNotifier { _feedList = await getRecommendedFeedsUseCase.execute( dailyLocationWeather: _dailyLocationWeather!, ); + _precacheList = await getSearchFeedsUseCase.execute(); if (_dailyLocationWeather != null) { // 현재 시간에 맞는 날씨 예보 빼내기 From c1c65d1d7bc177afd6af19104e1bbd37e9100641 Mon Sep 17 00:00:00 2001 From: hoogom88 Date: Tue, 4 Jun 2024 13:43:14 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Refactor:=20=EC=A3=BC=EC=84=9D=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/presentation/common/component/cached_image_widget.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/presentation/common/component/cached_image_widget.dart b/lib/presentation/common/component/cached_image_widget.dart index 7498c7cb..b5e23eb8 100644 --- a/lib/presentation/common/component/cached_image_widget.dart +++ b/lib/presentation/common/component/cached_image_widget.dart @@ -24,6 +24,7 @@ class CachedImageWidget extends StatelessWidget { return CachedNetworkImage( fit: _boxFit ?? BoxFit.cover, imageUrl: _imageUrl, + // Flip Card 위젯 높이와 동일 = 16 * 35 memCacheHeight: (16 * 35).cacheSize(context), progressIndicatorBuilder: (context, url, downloadProgress) => _progressIndicatorBuilder ?? From 9afb89c1c58a9b26882705fb0644d78f317ab329 Mon Sep 17 00:00:00 2001 From: hoogom88 Date: Tue, 4 Jun 2024 17:12:19 +0900 Subject: [PATCH 3/3] =?UTF-8?q?Refactor:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20import=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home/component/recommend_ootd_list_widget.dart | 7 +++---- lib/presentation/home/screen/home_screen.dart | 4 ++-- .../home/view_model/home_screen_view_model.dart | 1 - 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/presentation/home/component/recommend_ootd_list_widget.dart b/lib/presentation/home/component/recommend_ootd_list_widget.dart index abe511cd..e1f92cd7 100644 --- a/lib/presentation/home/component/recommend_ootd_list_widget.dart +++ b/lib/presentation/home/component/recommend_ootd_list_widget.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:collection/collection.dart'; import 'package:weaco/core/go_router/router_static.dart'; import 'package:weaco/domain/feed/model/feed.dart'; import 'package:weaco/domain/weather/model/daily_location_weather.dart'; @@ -43,13 +42,13 @@ class RecommendOotdListWidget extends StatelessWidget { : Expanded( child: ListView( scrollDirection: Axis.horizontal, - children: feedList.mapIndexed((index, element) => GestureDetector( + children: feedList.indexed.map((e) => GestureDetector( onTap: () => RouterStatic.pushToOotdDetail( context, - feed: element), + feed: e.$2), child: RecommendOotdWidget( feedList: feedList, - index: index, + index: e.$1, ), )).toList() ), diff --git a/lib/presentation/home/screen/home_screen.dart b/lib/presentation/home/screen/home_screen.dart index 7b82802d..00f2bce0 100644 --- a/lib/presentation/home/screen/home_screen.dart +++ b/lib/presentation/home/screen/home_screen.dart @@ -28,11 +28,11 @@ class _HomeScreenState extends State { Future.microtask( () async { await context.read().initHomeScreen(); - final tmp = context.read().precacheList; if (mounted) { + final tmp = context.read().precacheList; for (Feed e in tmp) { await precacheImage(CachedNetworkImageProvider(e.thumbnailImagePath), context); - }; + } } }, ); diff --git a/lib/presentation/home/view_model/home_screen_view_model.dart b/lib/presentation/home/view_model/home_screen_view_model.dart index 45615710..828bc10f 100644 --- a/lib/presentation/home/view_model/home_screen_view_model.dart +++ b/lib/presentation/home/view_model/home_screen_view_model.dart @@ -1,4 +1,3 @@ -import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:weaco/domain/feed/use_case/get_search_feeds_use_case.dart'; import 'package:weaco/presentation/common/style/image_path.dart';