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 20, 2025
2 parents 0b2b492 + cc82a19 commit fdc7893
Show file tree
Hide file tree
Showing 25 changed files with 377 additions and 238 deletions.
6 changes: 5 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
include: package:flutter_lints/flutter.yaml

analyzer:
exclude: [lib/**.freezed.dart, lib/**.g.dart]
exclude:
- lib/**.freezed.dart
- lib/**.g.dart
- lib/l10n/gen

linter:
# The lint rules applied to this project can be customized in the
Expand All @@ -29,6 +32,7 @@ linter:
prefer_final_locals: true
# prefer_final_parameters: true
prefer_final_in_for_each: true
always_declare_return_types: true
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
Expand Down
2 changes: 1 addition & 1 deletion lib/cook_page/recipe_card/default_recipe_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DefaultRecipeCard extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
spacing: spacing,
children: <Widget>[
_TitleBox(keepKoreanWord(L10ns.of(context).localized('${recipe.code}_name'))),
_TitleBox(L10ns.of(context).localized('${recipe.code}_name').untruncatedKoreanByNewline),
Image.asset(
'assets/images/items/${recipe.assetName}.png',
width: imageSize,
Expand Down
2 changes: 1 addition & 1 deletion lib/cook_page/recipe_card/detail_recipe_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DetailRecipeCard extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
spacing: spacing,
children: <Widget>[
_TitleBox(keepKoreanWord(L10ns.of(context).localized('${recipe.code}_name'))),
_TitleBox(L10ns.of(context).localized('${recipe.code}_name').untruncatedKoreanByNewline),
Image.asset(
'assets/images/items/${recipe.assetName}.png',
width: imageSize,
Expand Down
2 changes: 1 addition & 1 deletion lib/cook_page/recipe_card/simple_recipe_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SimpleRecipeCard extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
spacing: spacing,
children: <Widget>[
_TitleBox(keepKoreanWord(L10ns.of(context).localized('${recipe.code}_name'))),
_TitleBox(L10ns.of(context).localized('${recipe.code}_name').untruncatedKoreanByNewline),
Image.asset(
'assets/images/items/${recipe.assetName}.png',
width: imageSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ class NutrientConditionBox extends StatelessWidget {
phrases += [
FittedBox(
child: Text(
// TODO: Localize this string
'각 성장마다 선택한 비료를 $countOfNeededFertilizer번 사용해야 합니다.',
L10ns.of(context).nutrientConditionBox.secondaryText(countOfNeededFertilizer),
style: TextStyle(
fontFamily: FontFamily.pretendard,
fontSize: 14,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,26 @@ class FertilizerSelectionSection extends StatelessWidget {
FertilizerSelectionSection({
super.key,
SelectedFertilizerNotifier? notifier,
}) : _notifier = notifier ?? SelectedFertilizerNotifier(null);
OverlayPortalController? overlayController,
}) : _overlayController = overlayController ?? OverlayPortalController(),
_notifier = notifier ?? SelectedFertilizerNotifier(null);

final SelectedFertilizerNotifier _notifier;

final OverlayPortalController _overlayController;

@override
Widget build(BuildContext context) {
return Column(
spacing: 6,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const _FertilizerSelectionHeader(),
ChangeNotifierProvider.value(
value: _notifier,
MultiProvider(
providers: [
ChangeNotifierProvider.value(value: _notifier),
Provider.value(value: _overlayController),
],
child: const _FertilizerSelectionBody(),
),
],
Expand Down Expand Up @@ -230,9 +237,7 @@ class _GrowthFormulaButton extends StatefulWidget {
}

class _GrowthFormulaButtonState extends State<_GrowthFormulaButton> {
final _overlayController = OverlayPortalController();

Fertilizer _lastSelected = Items.growthFormulaStarter;
Fertilizer _lastSelectedFertilizer = Items.growthFormulaStarter;

@override
void initState() {
Expand All @@ -243,7 +248,7 @@ class _GrowthFormulaButtonState extends State<_GrowthFormulaButton> {
void _initLastSelectedFertilizer() {
final initialValue = widget.initialValue;
if (initialValue != null) {
_lastSelected = initialValue;
_lastSelectedFertilizer = initialValue;
}
}

Expand All @@ -265,9 +270,10 @@ class _GrowthFormulaButtonState extends State<_GrowthFormulaButton> {
@override
Widget build(BuildContext context) {
final selectedFertilizer = context.watch<SelectedFertilizerNotifier>();
final overlayController = context.read<OverlayPortalController>();

return OverlayPortal(
controller: _overlayController,
controller: overlayController,
overlayChildBuilder: (context) {
return Positioned(
top: _computeOverlayOffset(context).dy,
Expand All @@ -283,9 +289,9 @@ class _GrowthFormulaButtonState extends State<_GrowthFormulaButton> {
fertilizer: fertilizer,
onPressed: () {
selectedFertilizer.apply(fertilizer);
_overlayController.hide();
overlayController.hide();
setState(() {
_lastSelected = fertilizer;
_lastSelectedFertilizer = fertilizer;
});
},
);
Expand All @@ -297,8 +303,8 @@ class _GrowthFormulaButtonState extends State<_GrowthFormulaButton> {
);
},
child: _FertilizerIconButton(
fertilizer: _lastSelected,
onPressed: _overlayController.toggle,
fertilizer: _lastSelectedFertilizer,
onPressed: overlayController.toggle,
),
);
}
Expand Down
105 changes: 63 additions & 42 deletions lib/farm_page/edit_farm_set/farm_group_edit_window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class FarmGroupEditWindow extends StatefulWidget {

class _FarmGroupEditWindowState extends State<FarmGroupEditWindow> {
late final FarmGroupEditController controller;
final _overlayController = OverlayPortalController();

@override
void initState() {
Expand Down Expand Up @@ -67,59 +68,79 @@ class _FarmGroupEditWindowState extends State<FarmGroupEditWindow> {
Provider.value(value: this),
ChangeNotifierProvider.value(value: controller),
],
child: FittedBox(
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(18.0),
),
padding: const EdgeInsets.all(18.0),
child: Row(
spacing: 34,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Row(
spacing: 30,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
FertilizersInfoBox(),
CropsInfoBox(),
],
),
Column(
spacing: 34,
children: [
const FarmGroupCanvas(),
ValueListenableBuilder(
valueListenable: controller.farmGroupModelNotifier,
builder: (context, value, child) => const AnalysisView()),
],
),
Column(
spacing: 30.0,
child: GestureDetector(
onTap: () => _overlayController.hide(),
child: FittedBox(
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(18.0),
),
padding: const EdgeInsets.all(18.0),
child: IntrinsicHeight(
child: Row(
spacing: 20,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const _TitleTextField(),
Row(
spacing: 30,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const FertilizersInfoBox(),
VerticalDivider(
width: 1.0,
color: Colors.grey.shade300,
),
const CropsInfoBox(),
],
),
VerticalDivider(
width: 1.0,
color: Colors.grey.shade300,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 8,
spacing: 34,
children: [
_buildFarmTypeSelectionBox(),
_buildFarmGroupTypeSelectionBox(),
const FarmGroupCanvas(),
ValueListenableBuilder(
valueListenable: controller.farmGroupModelNotifier,
builder: (context, value, child) => const AnalysisView()),
],
),
CropSelectionSection(notifier: controller.selectedCropNotifier),
FertilizerSelectionSection(notifier: controller.selectedFertilizerNotifier),
const Row(
spacing: 20,
VerticalDivider(
width: 1.0,
color: Colors.grey.shade300,
),
Column(
spacing: 30.0,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_CancelButton(),
_OkButton(),
const _TitleTextField(),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 8,
children: [
_buildFarmTypeSelectionBox(),
_buildFarmGroupTypeSelectionBox(),
],
),
CropSelectionSection(notifier: controller.selectedCropNotifier),
FertilizerSelectionSection(
notifier: controller.selectedFertilizerNotifier,
overlayController: _overlayController,
),
const Row(
spacing: 20,
children: [
_CancelButton(),
_OkButton(),
],
),
],
),
],
),
],
),
),
),
),
Expand Down
42 changes: 25 additions & 17 deletions lib/farm_page/farm_grid/farm_card/farm_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,31 +61,39 @@ class _FarmCardFooter extends StatelessWidget {
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
final model = context.watch<FarmCardModel>();
final fertilizerAsset = model.linkedFertilizer?.fertilizer.assetName;
final fertilizerAmount = model.linkedFertilizer?.amount;

final linkedFertilizer = model.linkedFertilizer;

if (linkedFertilizer == null) {
return const SizedBox();
}

final fertilizerName = L10ns.of(context).localized(linkedFertilizer.fertilizer.code);

return Container(
height: 44,
margin: const EdgeInsets.all(1),
padding: const EdgeInsets.all(4),
color: colorScheme.surfaceContainerHighest,
child: Center(
// TODO: Wrap below Row with Tooltip.
child: Row(
spacing: 4,
mainAxisSize: MainAxisSize.min,
children: [
Image(
image: AssetImage('assets/images/items/$fertilizerAsset.png'),
),
Text(
'x $fertilizerAmount',
style: const TextStyle(
fontFamily: FontFamily.pretendard,
fontSize: 14,
child: Tooltip(
message: L10ns.of(context).farmCard.footerFertilizerTooltip(fertilizerName, linkedFertilizer.amount),
child: Row(
spacing: 4,
mainAxisSize: MainAxisSize.min,
children: [
Image(
image: AssetImage('assets/images/items/${linkedFertilizer.fertilizer.assetName}.png'),
),
),
],
Text(
'x ${linkedFertilizer.amount}',
style: const TextStyle(
fontFamily: FontFamily.pretendard,
fontSize: 14,
),
),
],
),
),
),
);
Expand Down
1 change: 0 additions & 1 deletion lib/farm_page/farm_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class _TopBar extends StatelessWidget {
children: [
_SeasonSelectionBox(),
_NewButton(),
SizedBox(width: 50),
_ShowAndHideCheckbox(),
],
),
Expand Down
34 changes: 0 additions & 34 deletions lib/farm_page/side_info_box/crops_info_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,40 +148,6 @@ class CropsInfoBox extends StatelessWidget {
}
}

class CropsInfoBoxTag extends StatelessWidget {
const CropsInfoBoxTag({
super.key,
this.onPressed,
this.size = const Size(50, 50),
required this.color,
});

final Color color;
final Size size;
final void Function()? onPressed;

@override
Widget build(BuildContext context) {
return Container(
width: size.width,
height: size.height,
decoration: BoxDecoration(
color: color,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(20),
bottomLeft: Radius.circular(20),
),
boxShadow: kElevationToShadow[2],
),
child: IconButton(
padding: const EdgeInsets.only(top: 4, bottom: 2),
onPressed: onPressed,
icon: Image.asset("assets/images/nutrients_manure_icon.png"),
),
);
}
}

class SeasonIndicator extends StatelessWidget {
const SeasonIndicator({
super.key,
Expand Down
Loading

0 comments on commit fdc7893

Please sign in to comment.