Skip to content

Commit 8623eff

Browse files
committed
fix: edit and create shared component to refactor logout_modal and delete_user_modal.
1 parent 34b4f00 commit 8623eff

4 files changed

Lines changed: 151 additions & 226 deletions

File tree

lib/presentation/my_page/my_page_modal/delete_user_modal.dart

Lines changed: 66 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:on_time_front/l10n/app_localizations.dart';
33
import 'package:on_time_front/core/di/di_setup.dart';
44
import 'package:on_time_front/domain/use-cases/delete_user_use_case.dart';
55
import 'package:on_time_front/domain/repositories/user_repository.dart';
6+
import 'package:on_time_front/presentation/shared/components/modal_wide_button.dart';
67

78
class DeleteUserModal {
89
Future<void> showDeleteUserModal(
@@ -68,81 +69,35 @@ class DeleteUserModal {
6869
Column(
6970
mainAxisSize: MainAxisSize.min,
7071
children: [
71-
SizedBox(
72-
width: 245,
73-
height: 43,
74-
child: TextButton(
75-
style: ButtonStyle(
76-
backgroundColor: WidgetStateProperty.all(
77-
colorScheme.surfaceContainerLow),
78-
shape: WidgetStateProperty.all(
79-
RoundedRectangleBorder(
80-
borderRadius: BorderRadius.circular(8),
81-
),
82-
),
83-
padding: WidgetStateProperty.all(
84-
const EdgeInsets.symmetric(
85-
vertical: 10, horizontal: 8),
86-
),
87-
alignment: Alignment.center,
88-
minimumSize:
89-
WidgetStateProperty.all(const Size(245, 43)),
90-
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
91-
visualDensity: VisualDensity.compact,
92-
),
93-
onPressed: () => Navigator.of(ctx).pop(),
94-
child: Text(
95-
AppLocalizations.of(context)!.keepUsing,
96-
textAlign: TextAlign.center,
97-
style: TextStyle(
98-
fontFamily: 'Pretendard',
99-
fontWeight: FontWeight.w600,
100-
fontSize: 16,
101-
height: 1.4,
102-
color: colorScheme.outline,
103-
),
104-
),
72+
ModalWideButton(
73+
text: AppLocalizations.of(context)!.keepUsing,
74+
color: colorScheme.surfaceContainerLow,
75+
textColor: colorScheme.outline,
76+
textStyle: TextStyle(
77+
fontFamily: 'Pretendard',
78+
fontWeight: FontWeight.w600,
79+
fontSize: 16,
80+
height: 1.4,
81+
color: colorScheme.outline,
10582
),
83+
onPressed: () => Navigator.of(ctx).pop(),
10684
),
10785
const SizedBox(height: 8),
108-
SizedBox(
109-
width: 245,
110-
height: 43,
111-
child: TextButton(
112-
style: ButtonStyle(
113-
backgroundColor:
114-
WidgetStateProperty.all(colorScheme.error),
115-
shape: WidgetStateProperty.all(
116-
RoundedRectangleBorder(
117-
borderRadius: BorderRadius.circular(8),
118-
),
119-
),
120-
padding: WidgetStateProperty.all(
121-
const EdgeInsets.symmetric(
122-
vertical: 10, horizontal: 8),
123-
),
124-
alignment: Alignment.center,
125-
minimumSize:
126-
WidgetStateProperty.all(const Size(245, 43)),
127-
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
128-
visualDensity: VisualDensity.compact,
129-
),
130-
onPressed: () {
131-
Navigator.of(ctx).pop();
132-
_showDeleteFeedbackModal(context, onConfirm);
133-
},
134-
child: Text(
135-
AppLocalizations.of(context)!.deleteAnyway,
136-
textAlign: TextAlign.center,
137-
style: TextStyle(
138-
fontFamily: 'Pretendard',
139-
fontWeight: FontWeight.w600,
140-
fontSize: 16,
141-
height: 1.4,
142-
color: colorScheme.onPrimary,
143-
),
144-
),
86+
ModalWideButton(
87+
text: AppLocalizations.of(context)!.deleteAnyway,
88+
color: colorScheme.error,
89+
textColor: colorScheme.onPrimary,
90+
textStyle: TextStyle(
91+
fontFamily: 'Pretendard',
92+
fontWeight: FontWeight.w600,
93+
fontSize: 16,
94+
height: 1.4,
95+
color: colorScheme.onPrimary,
14596
),
97+
onPressed: () {
98+
Navigator.of(ctx).pop();
99+
_showDeleteFeedbackModal(context, onConfirm);
100+
},
146101
),
147102
],
148103
)
@@ -262,97 +217,52 @@ class DeleteUserModal {
262217
Column(
263218
mainAxisSize: MainAxisSize.min,
264219
children: [
265-
SizedBox(
266-
width: 245,
267-
height: 43,
268-
child: TextButton(
269-
style: ButtonStyle(
270-
backgroundColor: WidgetStateProperty.all(
271-
colorScheme.surfaceContainerLow),
272-
shape: WidgetStateProperty.all(
273-
RoundedRectangleBorder(
274-
borderRadius: BorderRadius.circular(8),
275-
),
276-
),
277-
padding: WidgetStateProperty.all(
278-
const EdgeInsets.symmetric(
279-
vertical: 10, horizontal: 8),
280-
),
281-
alignment: Alignment.center,
282-
minimumSize:
283-
WidgetStateProperty.all(const Size(245, 43)),
284-
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
285-
visualDensity: VisualDensity.compact,
286-
),
287-
onPressed: () => Navigator.of(ctx).pop(),
288-
child: Text(
289-
AppLocalizations.of(context)!.keepUsingLong,
290-
textAlign: TextAlign.center,
291-
style: TextStyle(
292-
fontFamily: 'Pretendard',
293-
fontWeight: FontWeight.w600,
294-
fontSize: 16,
295-
height: 1.4,
296-
color: colorScheme.outline,
297-
),
298-
),
220+
ModalWideButton(
221+
text: AppLocalizations.of(context)!.keepUsingLong,
222+
color: colorScheme.surfaceContainerLow,
223+
textColor: colorScheme.outline,
224+
textStyle: TextStyle(
225+
fontFamily: 'Pretendard',
226+
fontWeight: FontWeight.w600,
227+
fontSize: 16,
228+
height: 1.4,
229+
color: colorScheme.outline,
299230
),
231+
onPressed: () => Navigator.of(ctx).pop(),
300232
),
301233
const SizedBox(height: 8),
302-
SizedBox(
303-
width: 245,
304-
height: 43,
305-
child: TextButton(
306-
style: ButtonStyle(
307-
backgroundColor:
308-
WidgetStateProperty.all(colorScheme.error),
309-
shape: WidgetStateProperty.all(
310-
RoundedRectangleBorder(
311-
borderRadius: BorderRadius.circular(8),
312-
),
313-
),
314-
padding: WidgetStateProperty.all(
315-
const EdgeInsets.symmetric(
316-
vertical: 10, horizontal: 8),
317-
),
318-
alignment: Alignment.center,
319-
minimumSize:
320-
WidgetStateProperty.all(const Size(245, 43)),
321-
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
322-
visualDensity: VisualDensity.compact,
323-
),
324-
onPressed: () async {
325-
Navigator.of(ctx).pop();
234+
ModalWideButton(
235+
text:
236+
AppLocalizations.of(context)!.sendFeedbackAndDelete,
237+
color: colorScheme.error,
238+
textColor: colorScheme.onPrimary,
239+
textStyle: TextStyle(
240+
fontFamily: 'Pretendard',
241+
fontWeight: FontWeight.w600,
242+
fontSize: 16,
243+
height: 1.4,
244+
color: colorScheme.onPrimary,
245+
),
246+
onPressed: () async {
247+
Navigator.of(ctx).pop();
326248

327-
try {
328-
final deleteUserUseCase =
329-
getIt<DeleteUserUseCase>();
330-
await deleteUserUseCase(controller.text);
331-
} catch (e) {
332-
debugPrint(e.toString());
333-
}
249+
try {
250+
final deleteUserUseCase =
251+
getIt<DeleteUserUseCase>();
252+
await deleteUserUseCase(controller.text);
253+
} catch (e) {
254+
debugPrint(e.toString());
255+
}
334256

335-
try {
336-
final userRepository = getIt<UserRepository>();
337-
await userRepository.signOut();
338-
} catch (e) {
339-
debugPrint(e.toString());
340-
}
257+
try {
258+
final userRepository = getIt<UserRepository>();
259+
await userRepository.signOut();
260+
} catch (e) {
261+
debugPrint(e.toString());
262+
}
341263

342-
onConfirm();
343-
},
344-
child: Text(
345-
AppLocalizations.of(context)!.sendFeedbackAndDelete,
346-
textAlign: TextAlign.center,
347-
style: TextStyle(
348-
fontFamily: 'Pretendard',
349-
fontWeight: FontWeight.w600,
350-
fontSize: 16,
351-
height: 1.4,
352-
color: colorScheme.onPrimary,
353-
),
354-
),
355-
),
264+
onConfirm();
265+
},
356266
),
357267
],
358268
)

lib/presentation/my_page/my_page_modal/logout_modal.dart

Lines changed: 29 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:flutter_bloc/flutter_bloc.dart';
33
import 'package:on_time_front/l10n/app_localizations.dart';
44
import 'package:on_time_front/presentation/app/bloc/auth/auth_bloc.dart';
5+
import 'package:on_time_front/presentation/shared/components/modal_button.dart';
56

67
Future<void> showLogoutModal(BuildContext context) async {
78
final colorScheme = Theme.of(context).colorScheme;
@@ -16,7 +17,7 @@ Future<void> showLogoutModal(BuildContext context) async {
1617
color: Colors.transparent,
1718
child: Container(
1819
width: 277,
19-
height: 120,
20+
height: 125,
2021
padding: const EdgeInsets.fromLTRB(16, 18, 16, 18),
2122
decoration: BoxDecoration(
2223
color: colorScheme.surface,
@@ -41,21 +42,35 @@ Future<void> showLogoutModal(BuildContext context) async {
4142
Row(
4243
mainAxisAlignment: MainAxisAlignment.center,
4344
children: [
44-
_ModalButton(
45-
width: 118.5,
46-
height: 43,
47-
backgroundColor: colorScheme.surfaceContainerLow,
48-
foregroundColor: colorScheme.outline,
49-
label: AppLocalizations.of(context)!.cancel,
45+
ModalButton(
46+
text: AppLocalizations.of(context)!.cancel,
47+
color: colorScheme.surfaceContainerLow,
48+
textColor: colorScheme.outline,
49+
textStyle: TextStyle(
50+
fontFamily: 'Pretendard',
51+
fontWeight: FontWeight.w600,
52+
fontStyle: FontStyle.normal,
53+
fontSize: 16,
54+
height: 1.4,
55+
letterSpacing: 0,
56+
color: colorScheme.outline,
57+
),
5058
onPressed: () => Navigator.of(ctx).pop(),
5159
),
5260
const SizedBox(width: 8),
53-
_ModalButton(
54-
width: 118.5,
55-
height: 43,
56-
backgroundColor: colorScheme.error,
57-
foregroundColor: colorScheme.onPrimary,
58-
label: AppLocalizations.of(context)!.logOut,
61+
ModalButton(
62+
text: AppLocalizations.of(context)!.logOut,
63+
color: colorScheme.error,
64+
textColor: colorScheme.onPrimary,
65+
textStyle: TextStyle(
66+
fontFamily: 'Pretendard',
67+
fontWeight: FontWeight.w600,
68+
fontStyle: FontStyle.normal,
69+
fontSize: 16,
70+
height: 1.4,
71+
letterSpacing: 0,
72+
color: colorScheme.onPrimary,
73+
),
5974
onPressed: () {
6075
Navigator.of(ctx).pop();
6176
context
@@ -74,59 +89,4 @@ Future<void> showLogoutModal(BuildContext context) async {
7489
);
7590
}
7691

77-
class _ModalButton extends StatelessWidget {
78-
const _ModalButton({
79-
required this.width,
80-
required this.height,
81-
required this.backgroundColor,
82-
required this.foregroundColor,
83-
required this.label,
84-
required this.onPressed,
85-
});
86-
87-
final double width;
88-
final double height;
89-
final Color backgroundColor;
90-
final Color foregroundColor;
91-
final String label;
92-
final VoidCallback onPressed;
93-
94-
@override
95-
Widget build(BuildContext context) {
96-
return SizedBox(
97-
width: width,
98-
height: height,
99-
child: TextButton(
100-
style: ButtonStyle(
101-
backgroundColor: WidgetStateProperty.all(backgroundColor),
102-
shape: WidgetStateProperty.all(
103-
RoundedRectangleBorder(
104-
borderRadius: BorderRadius.circular(8),
105-
),
106-
),
107-
minimumSize: WidgetStateProperty.all(Size(width, height)),
108-
padding: WidgetStateProperty.all(
109-
const EdgeInsets.symmetric(vertical: 10, horizontal: 8),
110-
),
111-
alignment: Alignment.center,
112-
visualDensity: VisualDensity.compact,
113-
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
114-
),
115-
onPressed: onPressed,
116-
child: Text(
117-
label,
118-
textAlign: TextAlign.center,
119-
style: TextStyle(
120-
fontFamily: 'Pretendard',
121-
fontWeight: FontWeight.w600,
122-
fontStyle: FontStyle.normal,
123-
fontSize: 16,
124-
height: 1.4,
125-
letterSpacing: 0,
126-
color: foregroundColor,
127-
),
128-
),
129-
),
130-
);
131-
}
132-
}
92+
// 공용 ModalButton 사용으로 교체

0 commit comments

Comments
 (0)