Skip to content

Commit 367d06c

Browse files
committed
BREAKING CHANGE: use segmented button
Update wish.dart: set default to daily
1 parent eb7ca9a commit 367d06c

File tree

4 files changed

+30
-70
lines changed

4 files changed

+30
-70
lines changed

lib/features/add_wish/view/add_wish_screen.dart

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,28 +70,35 @@ class AddWishScreen extends StatelessWidget {
7070
style: theme.textTheme.titleSmall?.copyWith(color: theme.colorScheme.primary),
7171
),
7272
const SizedBox(height: 8),
73-
Padding(
74-
padding: const EdgeInsets.all(8.0),
75-
child: Row(
76-
mainAxisAlignment: MainAxisAlignment.center,
77-
children: const [
78-
CustomRadioOutlinedButton(
79-
borderRadius: BorderRadius.horizontal(left: Radius.circular(50)),
80-
labelText: 'Harian',
81-
value: SavingPlan.daily,
82-
),
83-
CustomRadioOutlinedButton(
84-
borderRadius: null,
85-
labelText: 'Mingguan',
86-
value: SavingPlan.weekly,
87-
),
88-
CustomRadioOutlinedButton(
89-
borderRadius: BorderRadius.horizontal(right: Radius.circular(50)),
90-
labelText: 'Bulanan',
91-
value: SavingPlan.monthly,
92-
),
93-
],
94-
),
73+
Row(
74+
mainAxisAlignment: MainAxisAlignment.center,
75+
children: [
76+
BlocBuilder<AddWishBloc, AddWishState>(
77+
builder: (context, state) {
78+
return SegmentedButton<SavingPlan>(
79+
onSelectionChanged: (newSelection) {
80+
context.read<AddWishBloc>().add(WishSavingPlanChanged(savingPlan: newSelection.first));
81+
},
82+
showSelectedIcon: false,
83+
segments: const [
84+
ButtonSegment(
85+
value: SavingPlan.daily,
86+
label: Text('Harian'),
87+
),
88+
ButtonSegment(
89+
value: SavingPlan.weekly,
90+
label: Text('Mingguan'),
91+
),
92+
ButtonSegment(
93+
value: SavingPlan.monthly,
94+
label: Text('Bulanan'),
95+
),
96+
],
97+
selected: {state.newWish.savingPlan},
98+
);
99+
},
100+
),
101+
],
95102
),
96103
BlocBuilder<AddWishBloc, AddWishState>(
97104
builder: (context, state) {

lib/features/add_wish/widget/custom_radio_outlined_button.dart

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
export 'custom_radio_outlined_button.dart';
21
export 'image_picker.dart';
32
export 'my_text_form_field.dart';

lib/shared/model/wish/wish.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Wish extends Equatable {
2222
required this.id,
2323
required this.name,
2424
required this.savingTarget,
25-
required this.savingPlan,
25+
this.savingPlan = SavingPlan.daily,
2626
required this.savingNominal,
2727
required this.listSaving,
2828
required this.createdAt,

0 commit comments

Comments
 (0)