From 868cb2059fd64139565a09fe08befd42e78689db Mon Sep 17 00:00:00 2001 From: nain93 Date: Wed, 16 Aug 2023 07:38:06 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20snackbar=20=EC=8A=A4=ED=83=80=EC=9D=BC?= =?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 --- lib/screens/home/content_view.dart | 1 - lib/screens/home/hashtag_detail_view.dart | 3 +- .../home/tab_view/hashtag_tab_view.dart | 3 +- lib/widgets/snackbar.dart | 85 ++++++++++++------- 4 files changed, 56 insertions(+), 36 deletions(-) diff --git a/lib/screens/home/content_view.dart b/lib/screens/home/content_view.dart index 5c5b18d..6869934 100644 --- a/lib/screens/home/content_view.dart +++ b/lib/screens/home/content_view.dart @@ -46,7 +46,6 @@ class ContentView extends HookConsumerWidget { if (context.mounted) { snackbar.alert(context, '잘못된 링크입니다.\n$url'); } - throw Exception('Could not launch $url'); } } diff --git a/lib/screens/home/hashtag_detail_view.dart b/lib/screens/home/hashtag_detail_view.dart index c8d6494..1f4a3ba 100644 --- a/lib/screens/home/hashtag_detail_view.dart +++ b/lib/screens/home/hashtag_detail_view.dart @@ -149,7 +149,8 @@ class HashtagDetailView extends HookConsumerWidget { ); if (list.isEmpty) { if (context.mounted) { - snackbar.alert(context, '검색 결과가 없습니다.'); + snackbar.alert( + context, '#${searchTextController.text}로 모은 취향 콘텐츠가 없어요!'); } return; } diff --git a/lib/screens/home/tab_view/hashtag_tab_view.dart b/lib/screens/home/tab_view/hashtag_tab_view.dart index cb1b854..ca5e080 100644 --- a/lib/screens/home/tab_view/hashtag_tab_view.dart +++ b/lib/screens/home/tab_view/hashtag_tab_view.dart @@ -99,7 +99,8 @@ class HashtagTabView extends HookConsumerWidget { ); if (list.isEmpty) { if (context.mounted) { - snackbar.alert(context, '검색 결과가 없습니다.'); + snackbar.alert( + context, '#${searchTextController.text}로 모은 취향 콘텐츠가 없어요!'); } return; } diff --git a/lib/widgets/snackbar.dart b/lib/widgets/snackbar.dart index 9c4db1c..840368b 100644 --- a/lib/widgets/snackbar.dart +++ b/lib/widgets/snackbar.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:moa_app/constants/color_constants.dart'; +import 'package:moa_app/constants/font_constants.dart'; class _Snackbar { factory _Snackbar() { @@ -12,44 +13,62 @@ class _Snackbar { void alert( BuildContext context, String message, { - String? title, TextStyle? textStyle, - Color? backgroundColor = Colors.white, + Color? backgroundColor = AppColors.primaryColor, Duration duration = const Duration(seconds: 2), }) { var snackBar = SnackBar( + margin: const EdgeInsets.only(left: 15, right: 15, bottom: 100), dismissDirection: DismissDirection.down, - content: SizedBox( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Flexible( - child: Text( - message, - style: const TextStyle(color: AppColors.blackColor) - .merge(textStyle), - ), - ), - ClipOval( - child: Material( - child: InkWell( - child: const Padding( - padding: EdgeInsets.all(6), - child: Icon( - size: 14, - Icons.close_sharp, - ), - ), - onTap: () { - if (context.mounted) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - } - }), - ), - ), - ], - ), + content: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Flexible( + child: message.contains('#') + ? RichText( + text: TextSpan( + style: const H3TextStyle() + .merge( + const TextStyle( + color: AppColors.whiteColor, + ), + ) + .merge(textStyle), + children: [ + TextSpan( + style: const TextStyle( + fontWeight: FontConstants.fontWeightBold, + ), + text: message.substring( + 0, + message.indexOf('로'), + ), + ), + TextSpan( + style: const TextStyle( + fontWeight: FontConstants.fontWeightNormal, + ), + text: message.substring(message.indexOf('로')), + ), + ])) + : Text( + message, + style: const H3TextStyle() + .merge( + const TextStyle( + fontWeight: FontConstants.fontWeightNormal, + color: AppColors.whiteColor, + ), + ) + .merge(textStyle), + ), + ), + ], + ), + padding: const EdgeInsets.all(10), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(14), ), duration: duration, behavior: SnackBarBehavior.floating,