Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
woin2ee committed Feb 18, 2025
2 parents 7b3f63a + aa0d1b1 commit 8723f96
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 47 deletions.
92 changes: 51 additions & 41 deletions lib/farm_page/edit_farm_set/farm_group_edit_window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,7 @@ class _FarmGroupEditWindowState extends State<FarmGroupEditWindow> {
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 8,
children: [
ValueListenableBuilder(
valueListenable: controller.selectedFarmGroupTypeNotifier,
builder: (context, value, child) {
return _buildFarmTypeSelectionBox();
}),
_buildFarmTypeSelectionBox(),
_buildFarmGroupTypeSelectionBox(),
],
),
Expand All @@ -132,6 +128,9 @@ class _FarmGroupEditWindowState extends State<FarmGroupEditWindow> {

Widget _buildFarmTypeSelectionBox() {
return Builder(builder: (context) {
final controller = context.watch<FarmGroupEditController>();
final colorScheme = Theme.of(context).colorScheme;

return Row(
spacing: 10,
children: <Widget>[
Expand All @@ -146,6 +145,10 @@ class _FarmGroupEditWindowState extends State<FarmGroupEditWindow> {
FarmType.reverseDense => null,
},
},
style: ButtonStyle(
backgroundColor: WidgetStatePropertyAll(
controller.selectedFarmType == type ? colorScheme.primaryContainer : Colors.white),
),
child: Text(
type.localizedName(context),
style: const TextStyle(
Expand All @@ -159,20 +162,29 @@ class _FarmGroupEditWindowState extends State<FarmGroupEditWindow> {
}

Widget _buildFarmGroupTypeSelectionBox() {
return Row(
spacing: 10.0,
children: [
...FarmGroupType.values.map((type) => OutlinedButton(
onPressed: () => controller.setFarmGroupType(type),
child: Text(
type.name,
style: const TextStyle(
fontFamily: FontFamily.pretendard,
return Builder(builder: (context) {
final controller = context.watch<FarmGroupEditController>();
final colorScheme = Theme.of(context).colorScheme;

return Row(
spacing: 10.0,
children: [
...FarmGroupType.values.map((type) => OutlinedButton(
onPressed: () => controller.setFarmGroupType(type),
style: ButtonStyle(
backgroundColor: WidgetStatePropertyAll(
controller.selectedFarmGroupType == type ? colorScheme.primaryContainer : Colors.white),
),
),
)),
],
);
child: Text(
type.name,
style: const TextStyle(
fontFamily: FontFamily.pretendard,
),
),
)),
],
);
});
}
}

Expand All @@ -181,30 +193,28 @@ class _TitleTextField extends StatelessWidget {

@override
Widget build(BuildContext context) {
final controller = context.read<FarmGroupEditController>();
return Builder(builder: (context) {
final controller = context.watch<FarmGroupEditController>();

return Container(
padding: const EdgeInsets.only(left: 8.0),
width: 400,
child: ListenableBuilder(
listenable: controller.farmGroupModel,
builder: (context, child) {
return TextField(
controller: controller.titleEditingController,
decoration: InputDecoration(
floatingLabelBehavior: FloatingLabelBehavior.always,
labelText: 'Name',
hintText: (controller.farmGroupModel.hasAnyPlant)
? '${controller.farmGroupModel.suitableSeasons.map((season) => season.localizedName(context))}'
: '',
hintStyle: const TextStyle(
fontFamily: FontFamily.pretendard,
color: Colors.grey,
),
),
);
}),
);
return Container(
padding: const EdgeInsets.only(left: 8.0),
width: 400,
child: TextField(
controller: controller.titleEditingController,
decoration: InputDecoration(
floatingLabelBehavior: FloatingLabelBehavior.always,
labelText: 'Name',
hintText: (controller.farmGroupModel.hasAnyPlant)
? '${controller.farmGroupModel.suitableSeasons.map((season) => season.localizedName(context))}'
: '',
hintStyle: const TextStyle(
fontFamily: FontFamily.pretendard,
color: Colors.grey,
),
),
),
);
});
}
}

Expand Down
14 changes: 8 additions & 6 deletions lib/farm_page/farm_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ class _FarmPageState extends State<FarmPage> {
return ChangeNotifierProvider.value(
value: _controller,
builder: (context, child) {
final controller = context.watch<FarmPageController>();

return Theme(
data: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(seedColor: _controller.selectedSeason.personalColor),
colorScheme: ColorScheme.fromSeed(seedColor: controller.selectedSeason.personalColor),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down Expand Up @@ -179,9 +181,9 @@ class _NewButton extends StatelessWidget {
}

class _SeasonSelectionBox extends StatelessWidget {
_SeasonSelectionBox();
const _SeasonSelectionBox();

final List<Season> _seasons = [
static const List<Season> _seasons = [
Season.spring,
Season.summer,
Season.autumn,
Expand All @@ -191,15 +193,15 @@ class _SeasonSelectionBox extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Consumer<FarmPageController>(
builder: (context, model, child) => ToggleButtons(
builder: (context, controller, child) => ToggleButtons(
borderRadius: BorderRadius.circular(10),
constraints: const BoxConstraints(
minWidth: 70,
minHeight: 40,
),
isSelected: _seasons.map((season) => season == model.selectedSeason).toList(),
isSelected: _seasons.map((season) => season == controller.selectedSeason).toList(),
onPressed: (index) {
model.selectedSeason = _seasons[index];
controller.selectedSeason = _seasons[index];
},
children: [
...Season.values.map((season) => Padding(
Expand Down

0 comments on commit 8723f96

Please sign in to comment.