Skip to content

Commit d6a5c7b

Browse files
committed
Update my_expandable_fab.dart
1 parent 4fe59f6 commit d6a5c7b

File tree

1 file changed

+39
-25
lines changed

1 file changed

+39
-25
lines changed

lib/features/wish_detail/widget/my_expandable_fab.dart

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,24 @@ class MyExpandableFab extends StatelessWidget {
1818
overlayStyle: ExpandableFabOverlayStyle(
1919
color: Colors.black.withOpacity(0.5),
2020
),
21-
expandedFabSize: ExpandableFabSize.regular,
21+
openButtonBuilder: DefaultFloatingActionButtonBuilder(
22+
child: Container(
23+
decoration: BoxDecoration(
24+
borderRadius: BorderRadius.circular(10),
25+
),
26+
padding: const EdgeInsets.all(16),
27+
child: const Icon(Icons.edit),
28+
),
29+
),
30+
closeButtonBuilder: DefaultFloatingActionButtonBuilder(
31+
child: Container(
32+
decoration: BoxDecoration(
33+
borderRadius: BorderRadius.circular(10),
34+
),
35+
padding: const EdgeInsets.all(16),
36+
child: const Icon(Icons.close),
37+
),
38+
),
2239
children: [
2340
_FloatingActionButtons(
2441
onTap: () => showDialog(
@@ -40,10 +57,12 @@ class MyExpandableFab extends StatelessWidget {
4057
value: context.read<WishBloc>(),
4158
child: SavingFormDialog(
4259
title: 'Ambil Tabungan',
43-
onSubmit: () => context.read<WishBloc>().add(const TakeSavingEvent()),
60+
onSubmit: () =>
61+
context.read<WishBloc>().add(const TakeSavingEvent()),
4462
formKey: formKey,
4563
validator: (value) {
46-
if (int.parse((value).replaceAll('.', '')) > context.read<WishBloc>().state.wish.getTotalSaving()) {
64+
if (int.parse((value).replaceAll('.', '')) >
65+
context.read<WishBloc>().state.wish.getTotalSaving()) {
4766
return 'Nominal tidak boleh melebihi total tabungan terkumpul';
4867
}
4968
return null;
@@ -62,10 +81,17 @@ class MyExpandableFab extends StatelessWidget {
6281
value: context.read<WishBloc>(),
6382
child: SavingFormDialog(
6483
title: 'Menabung',
65-
onSubmit: () => context.read<WishBloc>().add(const AddSavingEvent()),
84+
onSubmit: () =>
85+
context.read<WishBloc>().add(const AddSavingEvent()),
6686
formKey: formKey,
6787
validator: (value) {
68-
if (int.parse((value).replaceAll('.', '')) > wish.savingTarget - context.read<WishBloc>().state.wish.getTotalSaving()) {
88+
if (int.parse((value).replaceAll('.', '')) >
89+
wish.savingTarget -
90+
context
91+
.read<WishBloc>()
92+
.state
93+
.wish
94+
.getTotalSaving()) {
6995
return 'Nominal yang ditabung melebihi kekurangan';
7096
}
7197
return null;
@@ -77,22 +103,6 @@ class MyExpandableFab extends StatelessWidget {
77103
icon: Icons.add,
78104
),
79105
],
80-
closeButtonStyle: ExpandableFabCloseButtonStyle(
81-
child: Container(
82-
decoration: BoxDecoration(
83-
borderRadius: BorderRadius.circular(10),
84-
),
85-
padding: const EdgeInsets.all(16),
86-
child: const Icon(Icons.close),
87-
),
88-
),
89-
child: Container(
90-
decoration: BoxDecoration(
91-
borderRadius: BorderRadius.circular(10),
92-
),
93-
padding: const EdgeInsets.all(16),
94-
child: const Icon(Icons.edit),
95-
),
96106
);
97107
}
98108

@@ -101,7 +111,8 @@ class MyExpandableFab extends StatelessWidget {
101111
return AlertDialog(
102112
backgroundColor: theme.colorScheme.surface,
103113
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
104-
title: const Text('Hapus tabungan?', style: TextStyle(fontSize: 24, fontWeight: FontWeight.normal)),
114+
title: const Text('Hapus tabungan?',
115+
style: TextStyle(fontSize: 24, fontWeight: FontWeight.normal)),
105116
actions: [
106117
TextButton(
107118
onPressed: () => Navigator.pop(context),
@@ -122,7 +133,8 @@ class MyExpandableFab extends StatelessWidget {
122133
}
123134

124135
class _FloatingActionButtons extends StatelessWidget {
125-
const _FloatingActionButtons({required this.onTap, required this.labelText, required this.icon});
136+
const _FloatingActionButtons(
137+
{required this.onTap, required this.labelText, required this.icon});
126138

127139
final VoidCallback onTap;
128140
final String labelText;
@@ -144,8 +156,10 @@ class _FloatingActionButtons extends StatelessWidget {
144156
borderRadius: BorderRadius.circular(10),
145157
),
146158
child: Padding(
147-
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 12),
148-
child: Text(labelText, style: const TextStyle(fontWeight: FontWeight.bold)),
159+
padding:
160+
const EdgeInsets.symmetric(vertical: 8.0, horizontal: 12),
161+
child: Text(labelText,
162+
style: const TextStyle(fontWeight: FontWeight.bold)),
149163
),
150164
),
151165
Container(

0 commit comments

Comments
 (0)