Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix from release #208

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions assets/l10n/en/stock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,25 @@ ingredient:
helper: |-
Setting this value helps you see how much of the ingredient is being used.
Leave blank or don't fill it in, and the value will automatically be set each time inventory is increased.
restockTitle: |-
The amount of ingredient you can restock each time.
For example, if 30 units of cheese cost 100 dollars,
fill in "30" for "Restock Unit" and "100" for "Restock Price."

This helps you quickly restock by price.
restockPrice:
label: Restock Price
helper: |-
The price per unit each time you restock.
When restocking, you can restock by price instead of quantity.
restockQuantity:
label: Restock Unit
helper: |-
The amount of ingredient you can restock per Restock Price.
For example, if 30 units of cheese cost 100 dollars,
fill in "30" for "Restock Unit" and "100" for "Restock Price."
restockDialog:
title:
- Each {quantity} costs {price} dollars
- Headline of the dialog for setting the restock price
- quantity:
price:
subtitle:
- Please enter the purchase price
- Helper text to remind users to enter the purchase price
quantity:
tab: Quantity
btn: Use Quantity
Expand Down
12 changes: 8 additions & 4 deletions assets/l10n/zh/stock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@ ingredient:
helper: |-
設定這個值可以幫助你一眼看出用了多少成分。
填空或不填寫則每次增加庫存,都會自動設定這值,
restockTitle: |-
每次補貨可以補貨多少成分。
例如,每 30 份起司要價 100 元,「補貨單位」就填寫 30,「補貨單價」就填寫 100。

這可以幫助你透過價錢快速補貨。
restockPrice:
label: 補貨單價
helper: |-
每次補貨時,每單位的價錢,補貨的時候可以透過價錢補貨而非單純的數量數量。
restockQuantity:
label: 補貨單位
helper: |-
每補貨單價可以補貨多少成分。例如,每 30 份起司要價 100 元,「補貨單位」就填寫 30,「補貨單價」就填寫 100。
restockDialog:
title:
- 目前每{quantity}個要價{price}元
subtitle: 請輸入購買價格
quantity:
tab: 數量
btn: 使用數量
Expand Down
5 changes: 1 addition & 4 deletions lib/components/linkify.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ class Linkify extends StatelessWidget {
style: linkStyle,
recognizer: TapGestureRecognizer()..onTap = element.launch,
)
: TextSpan(
text: element.text,
style: bodyTheme,
),
: TextSpan(text: element.text),
)
.toList(),
),
Expand Down
3 changes: 2 additions & 1 deletion lib/components/tutorial.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:possystem/components/linkify.dart';
import 'package:possystem/services/cache.dart';
import 'package:spotlight_ant/spotlight_ant.dart';

Expand Down Expand Up @@ -103,7 +104,7 @@ class Tutorial extends StatelessWidget {
child: Column(children: [
if (title != null) Text(title!, style: theme.textTheme.headlineMedium!.copyWith(color: Colors.white)),
const SizedBox(height: 16),
Text(message),
Linkify.fromString(message),
if (below != null) below!,
]),
),
Expand Down
6 changes: 3 additions & 3 deletions lib/helpers/setup_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ Future<void> setupExampleOrderAttrs() async {
id: 'adult', name: '${S.orderAttributeExampleAgeAdult} (13-60)', index: 2, isDefault: true),
'senior': OrderAttributeOption(id: 'senior', name: '${S.orderAttributeExampleAgeSenior} (60+)', index: 3),
},
),
)..prepareItem(),
OrderAttribute(
id: 'place',
name: S.orderAttributeExamplePlace,
Expand All @@ -241,7 +241,7 @@ Future<void> setupExampleOrderAttrs() async {
'dine-in':
OrderAttributeOption(id: 'dine-in', name: S.orderAttributeExamplePlaceDineIn, index: 2, modeValue: 1.1),
},
),
)..prepareItem(),
OrderAttribute(
id: 'eco-friendly',
name: S.orderAttributeExampleEcoFriendly,
Expand All @@ -253,7 +253,7 @@ Future<void> setupExampleOrderAttrs() async {
'reuseable-bottle': OrderAttributeOption(
id: 'reuseable-bottle', name: S.orderAttributeExampleEcoFriendlyReusableBottle, index: 1, modeValue: -30),
},
),
)..prepareItem(),
]) {
await OrderAttributes.instance.addItem(e);
}
Expand Down
21 changes: 18 additions & 3 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"@@locale": "en",
"@@last_modified": "2024-07-06T10:00:50.953962Z",
"@@last_modified": "2024-07-08T13:16:38.533669Z",
"@@author": "Lu Shueh Chou",
"settingTab": "Settings",
"settingVersion": "Version: {version}",
Expand Down Expand Up @@ -125,10 +125,25 @@
"stockIngredientAmountLabel": "Current Amount",
"stockIngredientAmountMaxLabel": "Maximum Amount",
"stockIngredientAmountMaxHelper": "Setting this value helps you see how much of the ingredient is being used.\nLeave blank or don't fill it in, and the value will automatically be set each time inventory is increased.",
"stockIngredientRestockTitle": "The amount of ingredient you can restock each time.\nFor example, if 30 units of cheese cost 100 dollars,\nfill in \"30\" for \"Restock Unit\" and \"100\" for \"Restock Price.\"\nThis helps you quickly restock by price.",
"stockIngredientRestockPriceLabel": "Restock Price",
"stockIngredientRestockPriceHelper": "The price per unit each time you restock.\nWhen restocking, you can restock by price instead of quantity.",
"stockIngredientRestockQuantityLabel": "Restock Unit",
"stockIngredientRestockQuantityHelper": "The amount of ingredient you can restock per Restock Price.\nFor example, if 30 units of cheese cost 100 dollars,\nfill in \"30\" for \"Restock Unit\" and \"100\" for \"Restock Price.\"",
"stockIngredientRestockDialogTitle": "Each {quantity} costs {price} dollars",
"@stockIngredientRestockDialogTitle": {
"description": "Headline of the dialog for setting the restock price",
"placeholders": {
"quantity": {
"type": "String"
},
"price": {
"type": "String"
}
}
},
"stockIngredientRestockDialogSubtitle": "Please enter the purchase price",
"@stockIngredientRestockDialogSubtitle": {
"description": "Helper text to remind users to enter the purchase price"
},
"stockIngredientRestockDialogQuantityTab": "Quantity",
"stockIngredientRestockDialogQuantityBtn": "Use Quantity",
"stockIngredientRestockDialogQuantityLabel": "Current Amount",
Expand Down
21 changes: 18 additions & 3 deletions lib/l10n/app_zh.arb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"@@locale": "zh",
"@@last_modified": "2024-07-06T10:00:50.976445Z",
"@@last_modified": "2024-07-08T13:16:38.559010Z",
"@@author": "Lu Shueh Chou",
"settingTab": "設定",
"settingVersion": "版本:{version}",
Expand Down Expand Up @@ -125,10 +125,25 @@
"stockIngredientAmountLabel": "現有庫存",
"stockIngredientAmountMaxLabel": "最大庫存",
"stockIngredientAmountMaxHelper": "設定這個值可以幫助你一眼看出用了多少成分。\n填空或不填寫則每次增加庫存,都會自動設定這值,",
"stockIngredientRestockTitle": "每次補貨可以補貨多少成分。\n例如,每 30 份起司要價 100 元,「補貨單位」就填寫 30,「補貨單價」就填寫 100。\n這可以幫助你透過價錢快速補貨。",
"stockIngredientRestockPriceLabel": "補貨單價",
"stockIngredientRestockPriceHelper": "每次補貨時,每單位的價錢,補貨的時候可以透過價錢補貨而非單純的數量數量。",
"stockIngredientRestockQuantityLabel": "補貨單位",
"stockIngredientRestockQuantityHelper": "每補貨單價可以補貨多少成分。例如,每 30 份起司要價 100 元,「補貨單位」就填寫 30,「補貨單價」就填寫 100。",
"stockIngredientRestockDialogTitle": "目前每{quantity}個要價{price}元",
"@stockIngredientRestockDialogTitle": {
"description": "Headline of the dialog for setting the restock price",
"placeholders": {
"quantity": {
"type": "String"
},
"price": {
"type": "String"
}
}
},
"stockIngredientRestockDialogSubtitle": "請輸入購買價格",
"@stockIngredientRestockDialogSubtitle": {
"description": "Helper text to remind users to enter the purchase price"
},
"stockIngredientRestockDialogQuantityTab": "數量",
"stockIngredientRestockDialogQuantityBtn": "使用數量",
"stockIngredientRestockDialogQuantityLabel": "現有庫存",
Expand Down
3 changes: 3 additions & 0 deletions lib/my_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class MyApp extends StatelessWidget {
S = localizations;
Intl.systemLocale = S.localeName;
Intl.defaultLocale = S.localeName;
// if no setup language, it will use system language. We try to
// catch system language here. Only first time calling will take
// effect.
LanguageSetting.instance.systemLanguage = S.localeName;
initializeDateFormatting(S.localeName);

Expand Down
10 changes: 10 additions & 0 deletions lib/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:possystem/ui/analysis/widgets/chart_modal.dart';
import 'package:possystem/ui/analysis/widgets/chart_reorder.dart';
import 'package:possystem/ui/menu/widgets/product_ingredient_reorder.dart';
import 'package:possystem/ui/stock/widgets/replenishment_apply.dart';
import 'package:possystem/ui/stock/widgets/stock_ingredient_restock_modal.dart';

import 'models/repository/menu.dart';
import 'models/repository/order_attributes.dart';
Expand Down Expand Up @@ -328,6 +329,14 @@ class Routes {
return StockIngredientModal(ingredient: Stock.instance.getItem(id));
},
),
GoRoute(
name: ingredientRestockModal,
path: 'i/:id/restock',
builder: (ctx, state) {
final id = state.pathParameters['id'] ?? '';
return StockIngredientRestockModal(ingredient: Stock.instance.getItem(id));
},
),
GoRoute(
name: quantity,
path: 'quantities',
Expand Down Expand Up @@ -463,6 +472,7 @@ class Routes {

static const ingredientNew = '/stock/new';
static const ingredientModal = '/stock/ingredient/modal';
static const ingredientRestockModal = '/stock/ingredient/restock/modal';
static const quantity = '/stock/quantities';
static const quantityNew = '/stock/quantity/new';
static const quantityModal = '/stock/quantity/modal';
Expand Down
11 changes: 7 additions & 4 deletions lib/settings/language_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import 'package:possystem/settings/setting.dart';

/// Language setting allow given null language which means system default.
class LanguageSetting extends Setting<Language?> {
Language _systemLanguage = Language.en;
Language? _systemLanguage;

static final instance = LanguageSetting._();

LanguageSetting._() {
value = Language.en;
value = null;
}

@override
Expand All @@ -20,11 +20,14 @@ class LanguageSetting extends Setting<Language?> {
@override
bool get registryForApp => true;

/// Set system language for fallback.
///
/// This is not idempotent, it will only set once.
set systemLanguage(String locale) {
_systemLanguage = parseLanguage(locale)!;
_systemLanguage ??= parseLanguage(locale)!;
}

Language get language => value ?? _systemLanguage;
Language get language => value ?? _systemLanguage ?? Language.en;

@override
void initialize() {
Expand Down
66 changes: 32 additions & 34 deletions lib/ui/order/cart/cart_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,6 @@ import 'package:possystem/models/repository/cart.dart';
import 'package:possystem/translator.dart';

class CartActions extends StatelessWidget {
static final List<BottomSheetAction> actions = <BottomSheetAction<CartActionTypes>>[
BottomSheetAction(
key: const Key('cart.action.discount'),
leading: const Icon(Icons.loyalty_sharp),
title: Text(S.orderCartActionDiscount),
returnValue: CartActionTypes.discount,
),
BottomSheetAction(
key: const Key('cart.action.price'),
leading: const Icon(Icons.attach_money_sharp),
title: Text(S.orderCartActionChangePrice),
returnValue: CartActionTypes.price,
),
BottomSheetAction(
key: const Key('cart.action.count'),
leading: const Icon(Icons.exposure_sharp),
title: Text(S.orderCartActionChangeCount),
returnValue: CartActionTypes.count,
),
BottomSheetAction(
key: const Key('cart.action.free'),
leading: const Icon(Icons.free_breakfast_sharp),
title: Text(S.orderCartActionFree),
returnValue: CartActionTypes.free,
),
BottomSheetAction(
key: const Key('cart.action.delete'),
leading: const Icon(KIcons.delete),
title: Text(S.orderCartActionDelete),
returnValue: CartActionTypes.delete,
),
];

const CartActions({super.key});

@override
Expand Down Expand Up @@ -127,7 +94,38 @@ class CartActions extends StatelessWidget {
static void showActions(BuildContext context) async {
final type = await showCircularBottomSheet<CartActionTypes>(
context,
actions: actions,
actions: <BottomSheetAction<CartActionTypes>>[
BottomSheetAction(
key: const Key('cart.action.discount'),
leading: const Icon(Icons.loyalty_sharp),
title: Text(S.orderCartActionDiscount),
returnValue: CartActionTypes.discount,
),
BottomSheetAction(
key: const Key('cart.action.price'),
leading: const Icon(Icons.attach_money_sharp),
title: Text(S.orderCartActionChangePrice),
returnValue: CartActionTypes.price,
),
BottomSheetAction(
key: const Key('cart.action.count'),
leading: const Icon(Icons.exposure_sharp),
title: Text(S.orderCartActionChangeCount),
returnValue: CartActionTypes.count,
),
BottomSheetAction(
key: const Key('cart.action.free'),
leading: const Icon(Icons.free_breakfast_sharp),
title: Text(S.orderCartActionFree),
returnValue: CartActionTypes.free,
),
BottomSheetAction(
key: const Key('cart.action.delete'),
leading: const Icon(KIcons.delete),
title: Text(S.orderCartActionDelete),
returnValue: CartActionTypes.delete,
),
],
);

if (type != null) {
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/order/order_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:possystem/components/linkify.dart';
import 'package:possystem/components/style/pop_button.dart';
import 'package:possystem/components/style/snackbar.dart';
import 'package:possystem/components/tutorial.dart';
Expand Down Expand Up @@ -142,7 +143,7 @@ void handleCheckoutStatus(BuildContext context, CheckoutStatus status) {
showMoreInfoSnackBar(
context,
S.orderSnackbarCashierUsingSmallMoney,
Text(S.orderSnackbarCashierUsingSmallMoneyHelper(Routes.getRoute('features/checkoutWarning'))),
Linkify.fromString(S.orderSnackbarCashierUsingSmallMoneyHelper(Routes.getRoute('features/checkoutWarning'))),
);
break;
default:
Expand Down
Loading