From fbe35f4e3fa07b493a0d86f01a53a6c7cdf3f9e0 Mon Sep 17 00:00:00 2001 From: KimDonghyeok Date: Fri, 7 Jun 2024 13:16:01 +0900 Subject: [PATCH 01/12] =?UTF-8?q?Feat:=20=EC=B6=94=EC=B2=9C=20=ED=94=BC?= =?UTF-8?q?=EB=93=9C=20=EB=A1=9C=EB=94=A9=20=EC=83=81=ED=83=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80,=20=EC=9D=BC=EB=B6=80=20=EC=9C=A0=EC=8A=A4=EC=BC=80?= =?UTF-8?q?=EC=9D=B4=EC=8A=A4=20Future.wait=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view_model/home_screen_view_model.dart | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) 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 828bc10f..297864e4 100644 --- a/lib/presentation/home/view_model/home_screen_view_model.dart +++ b/lib/presentation/home/view_model/home_screen_view_model.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + 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'; @@ -44,6 +46,7 @@ class HomeScreenViewModel with ChangeNotifier { // 전일 대비 온도차 double? _temperatureGap; String? _weatherBackgroundImage; + bool _isRecommendOotdLoading = false; DailyLocationWeather? get dailyLocationWeather => _dailyLocationWeather; Weather? get currentWeather => _currentWeather; @@ -56,18 +59,28 @@ class HomeScreenViewModel with ChangeNotifier { List get weatherByTimeList => _weatherByTimeList; String get errorMesasge => _errorMessage; String _errorMessage = ''; + bool get isRecommendOotdLoading => _isRecommendOotdLoading; Future initHomeScreen() async { _status = HomeScreenStatus.loading; + _isRecommendOotdLoading = true; notifyListeners(); try { _dailyLocationWeather = await getDailyLocationWeatherUseCase.execute(); + notifyListeners(); - _feedList = await getRecommendedFeedsUseCase.execute( - dailyLocationWeather: _dailyLocationWeather!, - ); - _precacheList = await getSearchFeedsUseCase.execute(); + final [futureFeedList, futurePrecacheList] = await Future.wait([ + getRecommendedFeedsUseCase.execute( + dailyLocationWeather: _dailyLocationWeather!, + ), + getSearchFeedsUseCase.execute(), + ]); + + _feedList = futureFeedList; + _precacheList = futurePrecacheList; + _isRecommendOotdLoading = false; + notifyListeners(); if (_dailyLocationWeather != null) { // 현재 시간에 맞는 날씨 예보 빼내기 From 1a23abf7f1e195638295550c8cdd366cd11f7bbf Mon Sep 17 00:00:00 2001 From: KimDonghyeok Date: Fri, 7 Jun 2024 13:25:37 +0900 Subject: [PATCH 02/12] =?UTF-8?q?Feat:=20RecommendOotdWidget=20=ED=95=84?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95,=20SkeletonRecommendOotdWidget?= =?UTF-8?q?=20=EC=9C=84=EC=A0=AF=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home/component/recommend_ootd_widget.dart | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/lib/presentation/home/component/recommend_ootd_widget.dart b/lib/presentation/home/component/recommend_ootd_widget.dart index 1de271fd..179e549e 100644 --- a/lib/presentation/home/component/recommend_ootd_widget.dart +++ b/lib/presentation/home/component/recommend_ootd_widget.dart @@ -1,16 +1,13 @@ import 'package:flutter/material.dart'; -import 'package:weaco/domain/feed/model/feed.dart'; import 'package:weaco/presentation/common/component/cached_image_widget.dart'; class RecommendOotdWidget extends StatelessWidget { const RecommendOotdWidget({ super.key, - required this.feedList, - required this.index, + required this.feedImagePath, }); - final List feedList; - final int index; + final String feedImagePath; @override Widget build(BuildContext context) { @@ -29,9 +26,33 @@ class RecommendOotdWidget extends StatelessWidget { child: ClipRRect( borderRadius: BorderRadius.circular(10), child: CachedImageWidget( - feedList[index].thumbnailImagePath, + feedImagePath, ), - + ), + ); + } +} + +class SkeletonRecommendOotdWidget extends StatelessWidget { + const SkeletonRecommendOotdWidget({super.key}); + + @override + Widget build(BuildContext context) { + return Container( + width: 110, + height: 110 * 16 / 9, + margin: const EdgeInsets.only(right: 25), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + boxShadow: const [ + BoxShadow( + color: Color.fromARGB(48, 95, 95, 95), + blurRadius: 2, + offset: Offset(5, 0), + ) + ]), + child: ClipRRect( + borderRadius: BorderRadius.circular(10), ), ); } From eb88f5369c836c6a8a8980c5873aba01a23fd206 Mon Sep 17 00:00:00 2001 From: KimDonghyeok Date: Fri, 7 Jun 2024 13:42:01 +0900 Subject: [PATCH 03/12] =?UTF-8?q?Feat:=20=EC=B6=94=EC=B2=9C=20OOTD=20?= =?UTF-8?q?=EB=A1=9C=EB=94=A9=20=EC=83=81=ED=83=9C=EC=97=90=20=EB=94=B0?= =?UTF-8?q?=EB=A5=B8=20shimmer=20=ED=9A=A8=EA=B3=BC=20=EC=A0=81=EC=9A=A9,?= =?UTF-8?q?=20RecommendOotdWidget=20=EC=A0=84=EB=8B=AC=EC=9D=B8=EC=9E=90?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/recommend_ootd_list_widget.dart | 229 ++++++++++++++++-- 1 file changed, 212 insertions(+), 17 deletions(-) diff --git a/lib/presentation/home/component/recommend_ootd_list_widget.dart b/lib/presentation/home/component/recommend_ootd_list_widget.dart index e1f92cd7..6f18c696 100644 --- a/lib/presentation/home/component/recommend_ootd_list_widget.dart +++ b/lib/presentation/home/component/recommend_ootd_list_widget.dart @@ -9,10 +9,12 @@ class RecommendOotdListWidget extends StatelessWidget { super.key, required this.dailyLocationWeather, required this.feedList, + required this.isLoading, }); final DailyLocationWeather? dailyLocationWeather; final List feedList; + final bool isLoading; @override Widget build(BuildContext context) { @@ -32,30 +34,223 @@ class RecommendOotdListWidget extends StatelessWidget { style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold), ), const SizedBox(height: 20), - feedList.isEmpty - ? const Center( - child: Text( - '아직 등록된 코디가 없어요 :( \n 가장 먼저 OOTD를 올려보세요! :D', - textAlign: TextAlign.center, - ), - ) - : Expanded( + isLoading + ? Expanded( child: ListView( scrollDirection: Axis.horizontal, - children: feedList.indexed.map((e) => GestureDetector( - onTap: () => RouterStatic.pushToOotdDetail( - context, - feed: e.$2), - child: RecommendOotdWidget( - feedList: feedList, - index: e.$1, + children: List.generate( + 20, + (index) => Shimmer( + linearGradient: _shimmerGradient, + child: ShimmerLoading( + isLoading: isLoading, + child: const SkeletonRecommendOotdWidget(), + ), ), - )).toList() + ).toList(), ), - ), + ) + : feedList.isEmpty + ? const Center( + child: Text( + '아직 등록된 코디가 없어요 :( \n 가장 먼저 OOTD를 올려보세요! :D', + textAlign: TextAlign.center, + ), + ) + : Expanded( + child: ListView( + scrollDirection: Axis.horizontal, + children: feedList.indexed + .map( + (e) => GestureDetector( + onTap: () => RouterStatic.pushToOotdDetail( + context, + feed: e.$2, + ), + child: RecommendOotdWidget( + feedImagePath: e.$2.thumbnailImagePath, + ), + ), + ) + .toList(), + ), + ), ], ), ), ); } } + +const _shimmerGradient = LinearGradient( + colors: [ + Color(0x305F5F5F), + Color(0x30FFFFFF), + Color(0x305F5F5F), + ], + stops: [ + 0.1, + 0.3, + 0.4, + ], + begin: Alignment(-1.0, -0.3), + end: Alignment(1.0, 0.3), + tileMode: TileMode.clamp, +); + +class Shimmer extends StatefulWidget { + static ShimmerState? of(BuildContext context) { + return context.findAncestorStateOfType(); + } + + const Shimmer({ + super.key, + required this.linearGradient, + this.child, + }); + + final LinearGradient linearGradient; + final Widget? child; + + @override + ShimmerState createState() => ShimmerState(); +} + +class ShimmerState extends State with SingleTickerProviderStateMixin { + late AnimationController _shimmerController; + + @override + void initState() { + super.initState(); + + _shimmerController = AnimationController.unbounded(vsync: this) + ..repeat(min: -0.5, max: 1.5, period: const Duration(milliseconds: 1000)); + } + + @override + void dispose() { + _shimmerController.dispose(); + super.dispose(); + } + + LinearGradient get gradient => LinearGradient( + colors: widget.linearGradient.colors, + stops: widget.linearGradient.stops, + begin: widget.linearGradient.begin, + end: widget.linearGradient.end, + transform: + _SlidingGradientTransform(slidePercent: _shimmerController.value), + ); + + bool get isSized => + (context.findRenderObject() as RenderBox?)?.hasSize ?? false; + + Size get size => (context.findRenderObject() as RenderBox).size; + + Offset getDescendantOffset({ + required RenderBox descendant, + Offset offset = Offset.zero, + }) { + final shimmerBox = context.findRenderObject() as RenderBox?; + return descendant.localToGlobal(offset, ancestor: shimmerBox); + } + + Listenable get shimmerChanges => _shimmerController; + + @override + Widget build(BuildContext context) { + return widget.child ?? const SizedBox(); + } +} + +class _SlidingGradientTransform extends GradientTransform { + const _SlidingGradientTransform({ + required this.slidePercent, + }); + + final double slidePercent; + + @override + Matrix4? transform(Rect bounds, {TextDirection? textDirection}) { + return Matrix4.translationValues(bounds.width * slidePercent, 0.0, 0.0); + } +} + +class ShimmerLoading extends StatefulWidget { + const ShimmerLoading({ + super.key, + required this.isLoading, + required this.child, + }); + + final bool isLoading; + final Widget child; + + @override + State createState() => _ShimmerLoadingState(); +} + +class _ShimmerLoadingState extends State { + Listenable? _shimmerChanges; + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + if (_shimmerChanges != null) { + _shimmerChanges!.removeListener(_onShimmerChange); + } + _shimmerChanges = Shimmer.of(context)?.shimmerChanges; + if (_shimmerChanges != null) { + _shimmerChanges!.addListener(_onShimmerChange); + } + } + + @override + void dispose() { + _shimmerChanges?.removeListener(_onShimmerChange); + super.dispose(); + } + + void _onShimmerChange() { + if (widget.isLoading) { + setState(() { + // Update the shimmer painting. + }); + } + } + + @override + Widget build(BuildContext context) { + if (!widget.isLoading) { + return widget.child; + } + + // Collect ancestor shimmer info. + final shimmer = Shimmer.of(context)!; + if (!shimmer.isSized) { + // The ancestor Shimmer widget has not laid + // itself out yet. Return an empty box. + return const SizedBox(); + } + final shimmerSize = shimmer.size; + final gradient = shimmer.gradient; + final offsetWithinShimmer = shimmer.getDescendantOffset( + descendant: context.findRenderObject() as RenderBox, + ); + + return ShaderMask( + blendMode: BlendMode.srcATop, + shaderCallback: (bounds) { + return gradient.createShader( + Rect.fromLTWH( + -offsetWithinShimmer.dx, + -offsetWithinShimmer.dy, + shimmerSize.width, + shimmerSize.height, + ), + ); + }, + child: widget.child, + ); + } +} From ef0b6d29d5bc623beba2015a42a19e6618ef04b9 Mon Sep 17 00:00:00 2001 From: KimDonghyeok Date: Fri, 7 Jun 2024 14:17:44 +0900 Subject: [PATCH 04/12] =?UTF-8?q?Feat:=20=ED=99=94=EB=A9=B4=20=EC=A0=84?= =?UTF-8?q?=EC=B2=B4=20=EB=A1=9C=EB=94=A9=20=EC=A0=9C=EA=B1=B0,=20?= =?UTF-8?q?=ED=99=88=ED=99=94=EB=A9=B4=20=EA=B0=81=20=EC=9A=94=EC=86=8C=20?= =?UTF-8?q?=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=9C=84=EC=A0=AF?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/presentation/home/screen/home_screen.dart | 220 +++++++++++++----- 1 file changed, 161 insertions(+), 59 deletions(-) diff --git a/lib/presentation/home/screen/home_screen.dart b/lib/presentation/home/screen/home_screen.dart index 00f2bce0..7a7e2b3b 100644 --- a/lib/presentation/home/screen/home_screen.dart +++ b/lib/presentation/home/screen/home_screen.dart @@ -3,9 +3,9 @@ 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/enum/exception_alert.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'; import 'package:weaco/presentation/common/util/alert_util.dart'; import 'package:weaco/presentation/home/component/recommend_ootd_list_widget.dart'; import 'package:weaco/presentation/home/component/weather_by_time_list_widget.dart'; @@ -27,11 +27,12 @@ class _HomeScreenState extends State { Future.microtask( () async { - await context.read().initHomeScreen(); - if (mounted) { - final tmp = context.read().precacheList; - for (Feed e in tmp) { - await precacheImage(CachedNetworkImageProvider(e.thumbnailImagePath), context); + context.read().initHomeScreen(); + final tmp = context.read().precacheList; + for (Feed e in tmp) { + if (mounted) { + await precacheImage( + CachedNetworkImageProvider(e.thumbnailImagePath), context); } } }, @@ -67,14 +68,13 @@ class _HomeScreenState extends State { return Scaffold( body: switch (viewModel.status) { HomeScreenStatus.error => const Center(child: Text('데이터를 불러올 수 없습니다.')), - HomeScreenStatus.loading => - const Center(child: CircularProgressIndicator()), HomeScreenStatus.idle => const SizedBox(), - HomeScreenStatus.success => Container( + HomeScreenStatus.loading || HomeScreenStatus.success => Container( decoration: BoxDecoration( image: DecorationImage( fit: BoxFit.fill, - image: NetworkImage(viewModel.backgroundImagePath), + image: + CachedNetworkImageProvider(viewModel.backgroundImagePath), ), ), child: SafeArea( @@ -95,37 +95,35 @@ class _HomeScreenState extends State { marginHeight: 40, )), // city - Text( - viewModel.dailyLocationWeather!.location.city, - style: const TextStyle( - fontSize: 15, - color: Colors.white, - ), - ), + viewModel.dailyLocationWeather != null + ? HomeScreenCityTextWidget( + city: viewModel + .dailyLocationWeather!.location.city) + : const HomeScreenCityTextWidget(city: '-'), const SizedBox(height: 4), // weather code description - Text( - WeatherCode.fromValue( - viewModel.currentWeather!.code) - .description, - style: const TextStyle( - fontSize: 15, - color: Colors.white, - ), - ), + viewModel.currentWeather != null + ? HomeScreenCurrentWeatherTextWidget( + currentWeather: WeatherCode.fromValue( + viewModel.currentWeather!.code) + .description) + : const HomeScreenCurrentWeatherTextWidget( + currentWeather: '-', + ), SizedBox( height: ReactionUtil.reactHeight( context: context, marginHeight: 20, )), // current temperature - Text( - '${viewModel.currentWeather!.temperature}℃', - style: const TextStyle( - color: Colors.white, - fontSize: 60, - ), - ), + viewModel.currentWeather != null + ? HomeScreenCurrentTemperatureTextWidget( + currentTemperature: + '${viewModel.currentWeather!.temperature}', + ) + : const HomeScreenCurrentTemperatureTextWidget( + currentTemperature: '-', + ), SizedBox( height: ReactionUtil.reactHeight( context: context, @@ -135,34 +133,25 @@ class _HomeScreenState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ // max, min temperature + Column( children: [ - Text( - '최고 ${viewModel.dailyLocationWeather!.highTemperature}℃', - style: const TextStyle( - fontSize: 15, - color: Colors.white, - shadows: [ - Shadow( - blurRadius: 4, - color: Color.fromARGB(165, 0, 0, 0), - offset: Offset(1, 1)), - ], - ), - ), - Text( - '최저 ${viewModel.dailyLocationWeather!.lowTemperature}℃', - style: const TextStyle( - fontSize: 15, - color: Colors.white, - shadows: [ - Shadow( - blurRadius: 4, - color: Color.fromARGB(165, 0, 0, 0), - offset: Offset(1, 1)), - ], - ), - ), + viewModel.dailyLocationWeather != null + ? HomeScreenDailyHighestTemperatureTextWidget( + highestTemperature: + '${viewModel.dailyLocationWeather!.highTemperature}', + ) + : const HomeScreenDailyHighestTemperatureTextWidget( + highestTemperature: '-', + ), + viewModel.dailyLocationWeather != null + ? HomeScreenDailyLowestTemperatureTextWidget( + lowestTemperature: + '${viewModel.dailyLocationWeather!.lowTemperature}', + ) + : const HomeScreenDailyLowestTemperatureTextWidget( + lowestTemperature: '-', + ), ], ), // 전일 대비 @@ -237,6 +226,7 @@ class _HomeScreenState extends State { // ootd list RecommendOotdListWidget( + isLoading: viewModel.isRecommendOotdLoading, dailyLocationWeather: viewModel.dailyLocationWeather, feedList: viewModel.feedList, ), @@ -249,3 +239,115 @@ class _HomeScreenState extends State { ); } } + +class HomeScreenCityTextWidget extends StatelessWidget { + final String city; + + const HomeScreenCityTextWidget({ + super.key, + required this.city, + }); + + @override + Widget build(BuildContext context) { + return Text( + city, + style: const TextStyle( + fontSize: 15, + color: Colors.white, + ), + ); + } +} + +class HomeScreenCurrentWeatherTextWidget extends StatelessWidget { + const HomeScreenCurrentWeatherTextWidget({ + super.key, + required this.currentWeather, + }); + + final String currentWeather; + + @override + Widget build(BuildContext context) { + return Text( + currentWeather, + style: const TextStyle( + fontSize: 15, + color: Colors.white, + ), + ); + } +} + +class HomeScreenCurrentTemperatureTextWidget extends StatelessWidget { + const HomeScreenCurrentTemperatureTextWidget({ + super.key, + required this.currentTemperature, + }); + + final String currentTemperature; + + @override + Widget build(BuildContext context) { + return Text( + '$currentTemperature℃', + style: const TextStyle( + color: Colors.white, + fontSize: 60, + ), + ); + } +} + +class HomeScreenDailyHighestTemperatureTextWidget extends StatelessWidget { + const HomeScreenDailyHighestTemperatureTextWidget({ + super.key, + required this.highestTemperature, + }); + + final String highestTemperature; + + @override + Widget build(BuildContext context) { + return Text( + '최고 $highestTemperature℃', + style: const TextStyle( + fontSize: 15, + color: Colors.white, + shadows: [ + Shadow( + blurRadius: 4, + color: Color.fromARGB(165, 0, 0, 0), + offset: Offset(1, 1)), + ], + ), + ); + } +} + +class HomeScreenDailyLowestTemperatureTextWidget extends StatelessWidget { + const HomeScreenDailyLowestTemperatureTextWidget({ + super.key, + required this.lowestTemperature, + }); + + final String lowestTemperature; + + @override + Widget build(BuildContext context) { + return Text( + '최저 $lowestTemperature℃', + style: const TextStyle( + fontSize: 15, + color: Colors.white, + shadows: [ + Shadow( + blurRadius: 4, + color: Color.fromARGB(165, 0, 0, 0), + offset: Offset(1, 1)), + ], + ), + ); + } +} From 954cbcdea57f8e526483c36011a1ff99ce4e3911 Mon Sep 17 00:00:00 2001 From: KimDonghyeok Date: Fri, 7 Jun 2024 14:31:52 +0900 Subject: [PATCH 05/12] =?UTF-8?q?Modify:=20=EB=AF=B8=EC=82=AC=EC=9A=A9=20i?= =?UTF-8?q?mport=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/presentation/home/view_model/home_screen_view_model.dart | 2 -- 1 file changed, 2 deletions(-) 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 297864e4..2a708cbc 100644 --- a/lib/presentation/home/view_model/home_screen_view_model.dart +++ b/lib/presentation/home/view_model/home_screen_view_model.dart @@ -1,5 +1,3 @@ -import 'dart:developer'; - 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'; From 7a03eb12bb11e69926b63d1ffa174647c859c956 Mon Sep 17 00:00:00 2001 From: KimDonghyeok Date: Sat, 8 Jun 2024 19:51:29 +0900 Subject: [PATCH 06/12] =?UTF-8?q?Feat:=20SkeletonRecommendOotdWidget=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C,=20RecommendOotdWidget=20=EC=9D=98=20feedIma?= =?UTF-8?q?gePath=20=ED=95=84=EB=93=9C=EB=A5=BC=20nullable=20=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=ED=95=98=EC=97=AC=20=EC=8A=A4=EC=BC=88=EB=A0=88?= =?UTF-8?q?=ED=86=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home/component/recommend_ootd_widget.dart | 37 ++++--------------- 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/lib/presentation/home/component/recommend_ootd_widget.dart b/lib/presentation/home/component/recommend_ootd_widget.dart index 179e549e..71dc49b6 100644 --- a/lib/presentation/home/component/recommend_ootd_widget.dart +++ b/lib/presentation/home/component/recommend_ootd_widget.dart @@ -4,10 +4,10 @@ import 'package:weaco/presentation/common/component/cached_image_widget.dart'; class RecommendOotdWidget extends StatelessWidget { const RecommendOotdWidget({ super.key, - required this.feedImagePath, + this.feedImagePath, }); - final String feedImagePath; + final String? feedImagePath; @override Widget build(BuildContext context) { @@ -25,34 +25,11 @@ class RecommendOotdWidget extends StatelessWidget { ]), child: ClipRRect( borderRadius: BorderRadius.circular(10), - child: CachedImageWidget( - feedImagePath, - ), - ), - ); - } -} - -class SkeletonRecommendOotdWidget extends StatelessWidget { - const SkeletonRecommendOotdWidget({super.key}); - - @override - Widget build(BuildContext context) { - return Container( - width: 110, - height: 110 * 16 / 9, - margin: const EdgeInsets.only(right: 25), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - boxShadow: const [ - BoxShadow( - color: Color.fromARGB(48, 95, 95, 95), - blurRadius: 2, - offset: Offset(5, 0), - ) - ]), - child: ClipRRect( - borderRadius: BorderRadius.circular(10), + child: feedImagePath != null + ? CachedImageWidget( + feedImagePath!, + ) + : null, ), ); } From 8410d0f2a80ce774a0196413be611beb17c4fe2f Mon Sep 17 00:00:00 2001 From: KimDonghyeok Date: Sat, 8 Jun 2024 19:51:46 +0900 Subject: [PATCH 07/12] =?UTF-8?q?Feat:=20SkeletonRecommendOotdWidget=20?= =?UTF-8?q?=EB=8C=80=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/presentation/home/component/recommend_ootd_list_widget.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/presentation/home/component/recommend_ootd_list_widget.dart b/lib/presentation/home/component/recommend_ootd_list_widget.dart index 6f18c696..551cbe54 100644 --- a/lib/presentation/home/component/recommend_ootd_list_widget.dart +++ b/lib/presentation/home/component/recommend_ootd_list_widget.dart @@ -44,7 +44,7 @@ class RecommendOotdListWidget extends StatelessWidget { linearGradient: _shimmerGradient, child: ShimmerLoading( isLoading: isLoading, - child: const SkeletonRecommendOotdWidget(), + child: const RecommendOotdWidget(), ), ), ).toList(), From 3b204feff1e0cf655c4a2dda63bdf0ff0c22b1ea Mon Sep 17 00:00:00 2001 From: KimDonghyeok Date: Sat, 8 Jun 2024 20:00:33 +0900 Subject: [PATCH 08/12] =?UTF-8?q?Feat:=20=EA=B0=81=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=20=EC=9C=84=EC=A0=AF=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home_screen_city_text_widget.dart | 21 ++++ ...creen_current_temperature_text_widget.dart | 21 ++++ ...me_screen_current_weather_text_widget.dart | 21 ++++ ...daily_highest_temperature_text_widget.dart | 27 ++++ ..._daily_lowest_temperature_text_widget.dart | 27 ++++ lib/presentation/home/screen/home_screen.dart | 119 +----------------- 6 files changed, 123 insertions(+), 113 deletions(-) create mode 100644 lib/presentation/home/component/home_screen_city_text_widget.dart create mode 100644 lib/presentation/home/component/home_screen_current_temperature_text_widget.dart create mode 100644 lib/presentation/home/component/home_screen_current_weather_text_widget.dart create mode 100644 lib/presentation/home/component/home_screen_daily_highest_temperature_text_widget.dart create mode 100644 lib/presentation/home/component/home_screen_daily_lowest_temperature_text_widget.dart diff --git a/lib/presentation/home/component/home_screen_city_text_widget.dart b/lib/presentation/home/component/home_screen_city_text_widget.dart new file mode 100644 index 00000000..6cd624c3 --- /dev/null +++ b/lib/presentation/home/component/home_screen_city_text_widget.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; + +class HomeScreenCityTextWidget extends StatelessWidget { + final String city; + + const HomeScreenCityTextWidget({ + super.key, + required this.city, + }); + + @override + Widget build(BuildContext context) { + return Text( + city, + style: const TextStyle( + fontSize: 15, + color: Colors.white, + ), + ); + } +} diff --git a/lib/presentation/home/component/home_screen_current_temperature_text_widget.dart b/lib/presentation/home/component/home_screen_current_temperature_text_widget.dart new file mode 100644 index 00000000..a4739eca --- /dev/null +++ b/lib/presentation/home/component/home_screen_current_temperature_text_widget.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; + +class HomeScreenCurrentTemperatureTextWidget extends StatelessWidget { + const HomeScreenCurrentTemperatureTextWidget({ + super.key, + required this.currentTemperature, + }); + + final String currentTemperature; + + @override + Widget build(BuildContext context) { + return Text( + '$currentTemperature℃', + style: const TextStyle( + color: Colors.white, + fontSize: 60, + ), + ); + } +} diff --git a/lib/presentation/home/component/home_screen_current_weather_text_widget.dart b/lib/presentation/home/component/home_screen_current_weather_text_widget.dart new file mode 100644 index 00000000..07c385ad --- /dev/null +++ b/lib/presentation/home/component/home_screen_current_weather_text_widget.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; + +class HomeScreenCurrentWeatherTextWidget extends StatelessWidget { + const HomeScreenCurrentWeatherTextWidget({ + super.key, + required this.currentWeather, + }); + + final String currentWeather; + + @override + Widget build(BuildContext context) { + return Text( + currentWeather, + style: const TextStyle( + fontSize: 15, + color: Colors.white, + ), + ); + } +} diff --git a/lib/presentation/home/component/home_screen_daily_highest_temperature_text_widget.dart b/lib/presentation/home/component/home_screen_daily_highest_temperature_text_widget.dart new file mode 100644 index 00000000..b6ee8006 --- /dev/null +++ b/lib/presentation/home/component/home_screen_daily_highest_temperature_text_widget.dart @@ -0,0 +1,27 @@ +import 'package:flutter/material.dart'; + +class HomeScreenDailyHighestTemperatureTextWidget extends StatelessWidget { + const HomeScreenDailyHighestTemperatureTextWidget({ + super.key, + required this.highestTemperature, + }); + + final String highestTemperature; + + @override + Widget build(BuildContext context) { + return Text( + '최고 $highestTemperature℃', + style: const TextStyle( + fontSize: 15, + color: Colors.white, + shadows: [ + Shadow( + blurRadius: 4, + color: Color.fromARGB(165, 0, 0, 0), + offset: Offset(1, 1)), + ], + ), + ); + } +} diff --git a/lib/presentation/home/component/home_screen_daily_lowest_temperature_text_widget.dart b/lib/presentation/home/component/home_screen_daily_lowest_temperature_text_widget.dart new file mode 100644 index 00000000..8c2ae994 --- /dev/null +++ b/lib/presentation/home/component/home_screen_daily_lowest_temperature_text_widget.dart @@ -0,0 +1,27 @@ +import 'package:flutter/material.dart'; + +class HomeScreenDailyLowestTemperatureTextWidget extends StatelessWidget { + const HomeScreenDailyLowestTemperatureTextWidget({ + super.key, + required this.lowestTemperature, + }); + + final String lowestTemperature; + + @override + Widget build(BuildContext context) { + return Text( + '최저 $lowestTemperature℃', + style: const TextStyle( + fontSize: 15, + color: Colors.white, + shadows: [ + Shadow( + blurRadius: 4, + color: Color.fromARGB(165, 0, 0, 0), + offset: Offset(1, 1)), + ], + ), + ); + } +} diff --git a/lib/presentation/home/screen/home_screen.dart b/lib/presentation/home/screen/home_screen.dart index 7a7e2b3b..58f6ed2b 100644 --- a/lib/presentation/home/screen/home_screen.dart +++ b/lib/presentation/home/screen/home_screen.dart @@ -1,12 +1,17 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:weaco/core/enum/weather_code.dart'; import 'package:weaco/core/util/reaction_util.dart'; import 'package:weaco/domain/feed/model/feed.dart'; import 'package:weaco/presentation/common/enum/exception_alert.dart'; import 'package:weaco/presentation/common/style/image_path.dart'; -import 'package:weaco/core/enum/weather_code.dart'; import 'package:weaco/presentation/common/util/alert_util.dart'; +import 'package:weaco/presentation/home/component/home_screen_city_text_widget.dart'; +import 'package:weaco/presentation/home/component/home_screen_current_temperature_text_widget.dart'; +import 'package:weaco/presentation/home/component/home_screen_current_weather_text_widget.dart'; +import 'package:weaco/presentation/home/component/home_screen_daily_highest_temperature_text_widget.dart'; +import 'package:weaco/presentation/home/component/home_screen_daily_lowest_temperature_text_widget.dart'; import 'package:weaco/presentation/home/component/recommend_ootd_list_widget.dart'; import 'package:weaco/presentation/home/component/weather_by_time_list_widget.dart'; import 'package:weaco/presentation/home/view_model/home_screen_view_model.dart'; @@ -239,115 +244,3 @@ class _HomeScreenState extends State { ); } } - -class HomeScreenCityTextWidget extends StatelessWidget { - final String city; - - const HomeScreenCityTextWidget({ - super.key, - required this.city, - }); - - @override - Widget build(BuildContext context) { - return Text( - city, - style: const TextStyle( - fontSize: 15, - color: Colors.white, - ), - ); - } -} - -class HomeScreenCurrentWeatherTextWidget extends StatelessWidget { - const HomeScreenCurrentWeatherTextWidget({ - super.key, - required this.currentWeather, - }); - - final String currentWeather; - - @override - Widget build(BuildContext context) { - return Text( - currentWeather, - style: const TextStyle( - fontSize: 15, - color: Colors.white, - ), - ); - } -} - -class HomeScreenCurrentTemperatureTextWidget extends StatelessWidget { - const HomeScreenCurrentTemperatureTextWidget({ - super.key, - required this.currentTemperature, - }); - - final String currentTemperature; - - @override - Widget build(BuildContext context) { - return Text( - '$currentTemperature℃', - style: const TextStyle( - color: Colors.white, - fontSize: 60, - ), - ); - } -} - -class HomeScreenDailyHighestTemperatureTextWidget extends StatelessWidget { - const HomeScreenDailyHighestTemperatureTextWidget({ - super.key, - required this.highestTemperature, - }); - - final String highestTemperature; - - @override - Widget build(BuildContext context) { - return Text( - '최고 $highestTemperature℃', - style: const TextStyle( - fontSize: 15, - color: Colors.white, - shadows: [ - Shadow( - blurRadius: 4, - color: Color.fromARGB(165, 0, 0, 0), - offset: Offset(1, 1)), - ], - ), - ); - } -} - -class HomeScreenDailyLowestTemperatureTextWidget extends StatelessWidget { - const HomeScreenDailyLowestTemperatureTextWidget({ - super.key, - required this.lowestTemperature, - }); - - final String lowestTemperature; - - @override - Widget build(BuildContext context) { - return Text( - '최저 $lowestTemperature℃', - style: const TextStyle( - fontSize: 15, - color: Colors.white, - shadows: [ - Shadow( - blurRadius: 4, - color: Color.fromARGB(165, 0, 0, 0), - offset: Offset(1, 1)), - ], - ), - ); - } -} From 0a9465ab117925f7b4b3888baad60ada13c002b1 Mon Sep 17 00:00:00 2001 From: KimDonghyeok Date: Sat, 8 Jun 2024 20:30:13 +0900 Subject: [PATCH 09/12] =?UTF-8?q?Feat:=20=EB=B7=B0=EB=AA=A8=EB=8D=B8=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20null=20check=20=EB=B6=80=EB=B6=84=20?= =?UTF-8?q?=EB=A9=94=EC=86=8C=EB=93=9C=EB=A1=9C=20=EB=B6=84=EB=A6=AC,=20?= =?UTF-8?q?=EC=9C=84=EC=A0=AF=20=EC=83=9D=EC=84=B1=EC=9E=90=20=EB=82=B4?= =?UTF-8?q?=EB=B6=80=EC=97=90=EC=84=9C=20=EC=82=BC=ED=95=AD=EC=97=B0?= =?UTF-8?q?=EC=82=B0=EC=9E=90=EB=A1=9C=20=EC=A0=84=EB=8B=AC=EC=9D=B8?= =?UTF-8?q?=EC=9E=90=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/presentation/home/screen/home_screen.dart | 71 +++++++++---------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/lib/presentation/home/screen/home_screen.dart b/lib/presentation/home/screen/home_screen.dart index 58f6ed2b..1b61a770 100644 --- a/lib/presentation/home/screen/home_screen.dart +++ b/lib/presentation/home/screen/home_screen.dart @@ -70,6 +70,10 @@ class _HomeScreenState extends State { ? viewModel.temperatureGap!.toStringAsFixed(1) : (-viewModel.temperatureGap!).toStringAsFixed(1); + bool _isNullValue(dynamic value) { + return value == null; + } + return Scaffold( body: switch (viewModel.status) { HomeScreenStatus.error => const Center(child: Text('데이터를 불러올 수 없습니다.')), @@ -100,35 +104,32 @@ class _HomeScreenState extends State { marginHeight: 40, )), // city - viewModel.dailyLocationWeather != null - ? HomeScreenCityTextWidget( - city: viewModel - .dailyLocationWeather!.location.city) - : const HomeScreenCityTextWidget(city: '-'), + HomeScreenCityTextWidget( + city: _isNullValue(viewModel.dailyLocationWeather) + ? '-' + : viewModel.dailyLocationWeather!.location.city, + ), const SizedBox(height: 4), // weather code description - viewModel.currentWeather != null - ? HomeScreenCurrentWeatherTextWidget( - currentWeather: WeatherCode.fromValue( - viewModel.currentWeather!.code) - .description) - : const HomeScreenCurrentWeatherTextWidget( - currentWeather: '-', - ), + HomeScreenCurrentWeatherTextWidget( + currentWeather: + _isNullValue(viewModel.currentWeather) + ? '-' + : WeatherCode.fromValue( + viewModel.currentWeather!.code) + .description), SizedBox( height: ReactionUtil.reactHeight( context: context, marginHeight: 20, )), // current temperature - viewModel.currentWeather != null - ? HomeScreenCurrentTemperatureTextWidget( - currentTemperature: - '${viewModel.currentWeather!.temperature}', - ) - : const HomeScreenCurrentTemperatureTextWidget( - currentTemperature: '-', - ), + HomeScreenCurrentTemperatureTextWidget( + currentTemperature: _isNullValue( + viewModel.currentWeather) + ? '-' + : '${viewModel.currentWeather!.temperature}', + ), SizedBox( height: ReactionUtil.reactHeight( context: context, @@ -141,22 +142,18 @@ class _HomeScreenState extends State { Column( children: [ - viewModel.dailyLocationWeather != null - ? HomeScreenDailyHighestTemperatureTextWidget( - highestTemperature: - '${viewModel.dailyLocationWeather!.highTemperature}', - ) - : const HomeScreenDailyHighestTemperatureTextWidget( - highestTemperature: '-', - ), - viewModel.dailyLocationWeather != null - ? HomeScreenDailyLowestTemperatureTextWidget( - lowestTemperature: - '${viewModel.dailyLocationWeather!.lowTemperature}', - ) - : const HomeScreenDailyLowestTemperatureTextWidget( - lowestTemperature: '-', - ), + HomeScreenDailyHighestTemperatureTextWidget( + highestTemperature: _isNullValue( + viewModel.dailyLocationWeather) + ? '-' + : '${viewModel.dailyLocationWeather!.highTemperature}', + ), + HomeScreenDailyLowestTemperatureTextWidget( + lowestTemperature: _isNullValue( + viewModel.dailyLocationWeather) + ? '-' + : '${viewModel.dailyLocationWeather!.lowTemperature}', + ), ], ), // 전일 대비 From 317812bbddc716bca8bccdda83c693f82a215a86 Mon Sep 17 00:00:00 2001 From: KimDonghyeok Date: Sat, 8 Jun 2024 20:30:13 +0900 Subject: [PATCH 10/12] =?UTF-8?q?Feat:=20=EB=B7=B0=EB=AA=A8=EB=8D=B8=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20null=20check=20=EB=B6=80=EB=B6=84=20?= =?UTF-8?q?=EB=A9=94=EC=86=8C=EB=93=9C=EB=A1=9C=20=EB=B6=84=EB=A6=AC,=20?= =?UTF-8?q?=EC=9C=84=EC=A0=AF=20=EC=83=9D=EC=84=B1=EC=9E=90=20=EB=82=B4?= =?UTF-8?q?=EB=B6=80=EC=97=90=EC=84=9C=20=EC=82=BC=ED=95=AD=EC=97=B0?= =?UTF-8?q?=EC=82=B0=EC=9E=90=EB=A1=9C=20=EC=A0=84=EB=8B=AC=EC=9D=B8?= =?UTF-8?q?=EC=9E=90=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/presentation/home/screen/home_screen.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/presentation/home/screen/home_screen.dart b/lib/presentation/home/screen/home_screen.dart index 1b61a770..71e7b8f1 100644 --- a/lib/presentation/home/screen/home_screen.dart +++ b/lib/presentation/home/screen/home_screen.dart @@ -70,7 +70,7 @@ class _HomeScreenState extends State { ? viewModel.temperatureGap!.toStringAsFixed(1) : (-viewModel.temperatureGap!).toStringAsFixed(1); - bool _isNullValue(dynamic value) { + bool isNullValue(dynamic value) { return value == null; } @@ -105,7 +105,7 @@ class _HomeScreenState extends State { )), // city HomeScreenCityTextWidget( - city: _isNullValue(viewModel.dailyLocationWeather) + city: isNullValue(viewModel.dailyLocationWeather) ? '-' : viewModel.dailyLocationWeather!.location.city, ), @@ -113,7 +113,7 @@ class _HomeScreenState extends State { // weather code description HomeScreenCurrentWeatherTextWidget( currentWeather: - _isNullValue(viewModel.currentWeather) + isNullValue(viewModel.currentWeather) ? '-' : WeatherCode.fromValue( viewModel.currentWeather!.code) @@ -125,7 +125,7 @@ class _HomeScreenState extends State { )), // current temperature HomeScreenCurrentTemperatureTextWidget( - currentTemperature: _isNullValue( + currentTemperature: isNullValue( viewModel.currentWeather) ? '-' : '${viewModel.currentWeather!.temperature}', @@ -143,13 +143,13 @@ class _HomeScreenState extends State { Column( children: [ HomeScreenDailyHighestTemperatureTextWidget( - highestTemperature: _isNullValue( + highestTemperature: isNullValue( viewModel.dailyLocationWeather) ? '-' : '${viewModel.dailyLocationWeather!.highTemperature}', ), HomeScreenDailyLowestTemperatureTextWidget( - lowestTemperature: _isNullValue( + lowestTemperature: isNullValue( viewModel.dailyLocationWeather) ? '-' : '${viewModel.dailyLocationWeather!.lowTemperature}', From 7b1403036eac7aa7b4f8b8d77bd60b171679e5b7 Mon Sep 17 00:00:00 2001 From: KimDonghyeok Date: Wed, 12 Jun 2024 16:45:08 +0900 Subject: [PATCH 11/12] =?UTF-8?q?Feat:=20=ED=99=88=ED=99=94=EB=A9=B4=20?= =?UTF-8?q?=ED=85=8D=EC=8A=A4=ED=8A=B8=20=EC=9C=84=EC=A0=AF=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC=20rollback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home_screen_city_text_widget.dart | 21 ----- ...creen_current_temperature_text_widget.dart | 21 ----- ...me_screen_current_weather_text_widget.dart | 21 ----- ...daily_highest_temperature_text_widget.dart | 27 ------- ..._daily_lowest_temperature_text_widget.dart | 27 ------- lib/presentation/home/screen/home_screen.dart | 80 +++++++++++-------- 6 files changed, 48 insertions(+), 149 deletions(-) delete mode 100644 lib/presentation/home/component/home_screen_city_text_widget.dart delete mode 100644 lib/presentation/home/component/home_screen_current_temperature_text_widget.dart delete mode 100644 lib/presentation/home/component/home_screen_current_weather_text_widget.dart delete mode 100644 lib/presentation/home/component/home_screen_daily_highest_temperature_text_widget.dart delete mode 100644 lib/presentation/home/component/home_screen_daily_lowest_temperature_text_widget.dart diff --git a/lib/presentation/home/component/home_screen_city_text_widget.dart b/lib/presentation/home/component/home_screen_city_text_widget.dart deleted file mode 100644 index 6cd624c3..00000000 --- a/lib/presentation/home/component/home_screen_city_text_widget.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:flutter/material.dart'; - -class HomeScreenCityTextWidget extends StatelessWidget { - final String city; - - const HomeScreenCityTextWidget({ - super.key, - required this.city, - }); - - @override - Widget build(BuildContext context) { - return Text( - city, - style: const TextStyle( - fontSize: 15, - color: Colors.white, - ), - ); - } -} diff --git a/lib/presentation/home/component/home_screen_current_temperature_text_widget.dart b/lib/presentation/home/component/home_screen_current_temperature_text_widget.dart deleted file mode 100644 index a4739eca..00000000 --- a/lib/presentation/home/component/home_screen_current_temperature_text_widget.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:flutter/material.dart'; - -class HomeScreenCurrentTemperatureTextWidget extends StatelessWidget { - const HomeScreenCurrentTemperatureTextWidget({ - super.key, - required this.currentTemperature, - }); - - final String currentTemperature; - - @override - Widget build(BuildContext context) { - return Text( - '$currentTemperature℃', - style: const TextStyle( - color: Colors.white, - fontSize: 60, - ), - ); - } -} diff --git a/lib/presentation/home/component/home_screen_current_weather_text_widget.dart b/lib/presentation/home/component/home_screen_current_weather_text_widget.dart deleted file mode 100644 index 07c385ad..00000000 --- a/lib/presentation/home/component/home_screen_current_weather_text_widget.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:flutter/material.dart'; - -class HomeScreenCurrentWeatherTextWidget extends StatelessWidget { - const HomeScreenCurrentWeatherTextWidget({ - super.key, - required this.currentWeather, - }); - - final String currentWeather; - - @override - Widget build(BuildContext context) { - return Text( - currentWeather, - style: const TextStyle( - fontSize: 15, - color: Colors.white, - ), - ); - } -} diff --git a/lib/presentation/home/component/home_screen_daily_highest_temperature_text_widget.dart b/lib/presentation/home/component/home_screen_daily_highest_temperature_text_widget.dart deleted file mode 100644 index b6ee8006..00000000 --- a/lib/presentation/home/component/home_screen_daily_highest_temperature_text_widget.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'package:flutter/material.dart'; - -class HomeScreenDailyHighestTemperatureTextWidget extends StatelessWidget { - const HomeScreenDailyHighestTemperatureTextWidget({ - super.key, - required this.highestTemperature, - }); - - final String highestTemperature; - - @override - Widget build(BuildContext context) { - return Text( - '최고 $highestTemperature℃', - style: const TextStyle( - fontSize: 15, - color: Colors.white, - shadows: [ - Shadow( - blurRadius: 4, - color: Color.fromARGB(165, 0, 0, 0), - offset: Offset(1, 1)), - ], - ), - ); - } -} diff --git a/lib/presentation/home/component/home_screen_daily_lowest_temperature_text_widget.dart b/lib/presentation/home/component/home_screen_daily_lowest_temperature_text_widget.dart deleted file mode 100644 index 8c2ae994..00000000 --- a/lib/presentation/home/component/home_screen_daily_lowest_temperature_text_widget.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'package:flutter/material.dart'; - -class HomeScreenDailyLowestTemperatureTextWidget extends StatelessWidget { - const HomeScreenDailyLowestTemperatureTextWidget({ - super.key, - required this.lowestTemperature, - }); - - final String lowestTemperature; - - @override - Widget build(BuildContext context) { - return Text( - '최저 $lowestTemperature℃', - style: const TextStyle( - fontSize: 15, - color: Colors.white, - shadows: [ - Shadow( - blurRadius: 4, - color: Color.fromARGB(165, 0, 0, 0), - offset: Offset(1, 1)), - ], - ), - ); - } -} diff --git a/lib/presentation/home/screen/home_screen.dart b/lib/presentation/home/screen/home_screen.dart index 71e7b8f1..c315a21b 100644 --- a/lib/presentation/home/screen/home_screen.dart +++ b/lib/presentation/home/screen/home_screen.dart @@ -7,11 +7,6 @@ import 'package:weaco/domain/feed/model/feed.dart'; import 'package:weaco/presentation/common/enum/exception_alert.dart'; import 'package:weaco/presentation/common/style/image_path.dart'; import 'package:weaco/presentation/common/util/alert_util.dart'; -import 'package:weaco/presentation/home/component/home_screen_city_text_widget.dart'; -import 'package:weaco/presentation/home/component/home_screen_current_temperature_text_widget.dart'; -import 'package:weaco/presentation/home/component/home_screen_current_weather_text_widget.dart'; -import 'package:weaco/presentation/home/component/home_screen_daily_highest_temperature_text_widget.dart'; -import 'package:weaco/presentation/home/component/home_screen_daily_lowest_temperature_text_widget.dart'; import 'package:weaco/presentation/home/component/recommend_ootd_list_widget.dart'; import 'package:weaco/presentation/home/component/weather_by_time_list_widget.dart'; import 'package:weaco/presentation/home/view_model/home_screen_view_model.dart'; @@ -104,31 +99,39 @@ class _HomeScreenState extends State { marginHeight: 40, )), // city - HomeScreenCityTextWidget( - city: isNullValue(viewModel.dailyLocationWeather) - ? '-' - : viewModel.dailyLocationWeather!.location.city, + Text( + viewModel.dailyLocationWeather?.location.city ?? + '-', + style: const TextStyle( + fontSize: 15, + color: Colors.white, + ), ), const SizedBox(height: 4), // weather code description - HomeScreenCurrentWeatherTextWidget( - currentWeather: - isNullValue(viewModel.currentWeather) - ? '-' - : WeatherCode.fromValue( - viewModel.currentWeather!.code) - .description), + Text( + viewModel.currentWeather != null + ? WeatherCode.fromValue( + viewModel.currentWeather!.code) + .description + : '-', + style: const TextStyle( + fontSize: 15, + color: Colors.white, + ), + ), SizedBox( height: ReactionUtil.reactHeight( context: context, marginHeight: 20, )), // current temperature - HomeScreenCurrentTemperatureTextWidget( - currentTemperature: isNullValue( - viewModel.currentWeather) - ? '-' - : '${viewModel.currentWeather!.temperature}', + Text( + '${viewModel.currentWeather?.temperature ?? '-'}℃', + style: const TextStyle( + color: Colors.white, + fontSize: 60, + ), ), SizedBox( height: ReactionUtil.reactHeight( @@ -139,20 +142,33 @@ class _HomeScreenState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ // max, min temperature - Column( children: [ - HomeScreenDailyHighestTemperatureTextWidget( - highestTemperature: isNullValue( - viewModel.dailyLocationWeather) - ? '-' - : '${viewModel.dailyLocationWeather!.highTemperature}', + Text( + '최고 ${viewModel.dailyLocationWeather?.highTemperature ?? '-'}℃', + style: const TextStyle( + fontSize: 15, + color: Colors.white, + shadows: [ + Shadow( + blurRadius: 4, + color: Color.fromARGB(165, 0, 0, 0), + offset: Offset(1, 1)), + ], + ), ), - HomeScreenDailyLowestTemperatureTextWidget( - lowestTemperature: isNullValue( - viewModel.dailyLocationWeather) - ? '-' - : '${viewModel.dailyLocationWeather!.lowTemperature}', + Text( + '최저 ${viewModel.dailyLocationWeather?.lowTemperature ?? '-'}℃', + style: const TextStyle( + fontSize: 15, + color: Colors.white, + shadows: [ + Shadow( + blurRadius: 4, + color: Color.fromARGB(165, 0, 0, 0), + offset: Offset(1, 1)), + ], + ), ), ], ), From 78e57887b50842eeb60f3b9c7b2a02453c79896d Mon Sep 17 00:00:00 2001 From: KimDonghyeok Date: Wed, 12 Jun 2024 16:46:58 +0900 Subject: [PATCH 12/12] =?UTF-8?q?Feat:=20=ED=99=88=ED=99=94=EB=A9=B4=20?= =?UTF-8?q?=ED=85=8D=EC=8A=A4=ED=8A=B8=20=EC=9C=84=EC=A0=AF=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC=20rollback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/presentation/home/screen/home_screen.dart | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/presentation/home/screen/home_screen.dart b/lib/presentation/home/screen/home_screen.dart index c315a21b..a1df91d3 100644 --- a/lib/presentation/home/screen/home_screen.dart +++ b/lib/presentation/home/screen/home_screen.dart @@ -65,10 +65,6 @@ class _HomeScreenState extends State { ? viewModel.temperatureGap!.toStringAsFixed(1) : (-viewModel.temperatureGap!).toStringAsFixed(1); - bool isNullValue(dynamic value) { - return value == null; - } - return Scaffold( body: switch (viewModel.status) { HomeScreenStatus.error => const Center(child: Text('데이터를 불러올 수 없습니다.')),