Skip to content

Commit

Permalink
fix: snackbar 스타일 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
nain93 committed Aug 15, 2023
1 parent 31e9d1b commit 868cb20
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 36 deletions.
1 change: 0 additions & 1 deletion lib/screens/home/content_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class ContentView extends HookConsumerWidget {
if (context.mounted) {
snackbar.alert(context, '잘못된 링크입니다.\n$url');
}
throw Exception('Could not launch $url');
}
}

Expand Down
3 changes: 2 additions & 1 deletion lib/screens/home/hashtag_detail_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ class HashtagDetailView extends HookConsumerWidget {
);
if (list.isEmpty) {
if (context.mounted) {
snackbar.alert(context, '검색 결과가 없습니다.');
snackbar.alert(
context, '#${searchTextController.text}로 모은 취향 콘텐츠가 없어요!');
}
return;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/screens/home/tab_view/hashtag_tab_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ class HashtagTabView extends HookConsumerWidget {
);
if (list.isEmpty) {
if (context.mounted) {
snackbar.alert(context, '검색 결과가 없습니다.');
snackbar.alert(
context, '#${searchTextController.text}로 모은 취향 콘텐츠가 없어요!');
}
return;
}
Expand Down
85 changes: 52 additions & 33 deletions lib/widgets/snackbar.dart
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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,
Expand Down

0 comments on commit 868cb20

Please sign in to comment.