Skip to content

Commit

Permalink
fix: receipt add attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
evan361425 committed Nov 10, 2024
1 parent c735e26 commit 7132dcb
Show file tree
Hide file tree
Showing 20 changed files with 304 additions and 294 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,6 @@ jobs:

- name: Push to GitHub
run: |
file='android/fastlane/metadata/android/%s/changelogs/${{ needs.check-version.outputs.build_code }}.txt'
printf "Source file: $file\n" "en-US"
printf '%s\n' "$(cat <<EOF
${{ needs.get-release.outputs.changelog }}
EOF
)" > $(printf "$file" "en-US")
bash android/fastlane/translate-changelog.sh "$file" '${{ secrets.GOOGLE_AI_API_KEY }}'
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add --all
git commit . -m "doc: changelog for ${{ needs.check-version.outputs.tag }}"
git push
# Replace the tag to reference the most recent commit
git tag -f ${{ needs.check-version.outputs.tag }}
git push -f origin --tags
# Update release tag name for later deploy to playstore
curl -X PATCH \
-H 'Accept: application/vnd.github.v3+json' \
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ bump: ## Bump beta version
code=$$(($$code + 1)); \
sed -i.bk '5s/version: .*/version: '$$version+$$code'/' pubspec.yaml; \
rm pubspec.yaml.bk; \
git add pubspec.yaml; \
bash scripts/bump-after.sh v$$version $$code \
read -p "Are you satisfied with the changes? (y/n): " confirm; \
if [[ $$confirm != "y" ]]; then exit 1; fi; \
git add .; \
git commit -m "chore: bump to $$version+$$code"; \
git tag "v$$version"; \
git push; \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
🚀 Features
## 🚀 Features

Support bluetooth printers #212 : evan361425
- Support bluetooth printers #212 : evan361425
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
🚀 新功能

• 支援藍牙出單機 #212 : evan361425
• 支援藍牙出單機 #212 : evan361425
6 changes: 2 additions & 4 deletions android/fastlane/translate-changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ zh-TW Traditional Chinese
local langCode langName prompt changelog response
langCode="$(echo "$lang" | cut -d' ' -f1)"
langName="$(echo "$lang" | cut -d' ' -f2-)"
echo "Translating changelog to $langName ($langCode)..."
echo "===== Translating changelog to $langName ($langCode)..."

prompt="$(printf "$(cat android/fastlane/translate-prompt.txt)" "$langName")"
echo "Prompt: $prompt"
response="ok"
echo "Fixed response: $response"

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro:generateContent?key=$googleApiKey" \
-H 'Content-Type: application/json' \
Expand All @@ -69,7 +67,7 @@ zh-TW Traditional Chinese
{role: "user", parts: [{text: $changelog}]}
]}')" \
| jq -r '.candidates[0].content.parts[0].text' \
> "$(printf "$changelogFile" "$langCode")"
| tee "$(printf "$changelogFile" "$langCode")"
done <<< "$languages"
}

Expand Down
14 changes: 0 additions & 14 deletions assets/l10n/en/order_attribute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,3 @@ option:
value: # Options can have values, this is the text for `OrderAttributeValue`
empty: No price impact
free: Free
discount:
increase:
- Increase to {value} times
- value: {type: num, format: decimalPattern}
decrease:
- Decrease to {value} times
- value: {type: num, format: decimalPattern}
price:
increase:
- Increase by {value} dollars
- value:
decrease:
- Decrease by {value} dollars
- value:
9 changes: 6 additions & 3 deletions assets/l10n/en/printer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,16 @@ receipt:
title: Receipt
column:
name: Item
price: Unit
count: Qty
total: Sub.
price: U/P
count: QTY
total: TOT
time: Time
discount:
label: Discount
origin: Origin
addOns:
label: Add-Ons
adjustment: Adj
total: Total
paid: Paid
price: Price
Expand Down
6 changes: 0 additions & 6 deletions assets/l10n/zh/order_attribute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,3 @@ option:
value:
empty: 不影響價錢
free: 免費
discount:
increase: 增加至 {value} 倍
decrease: 減少至 {value} 倍
price:
increase: 增加 {value} 元
decrease: 減少 {value} 元
3 changes: 3 additions & 0 deletions assets/l10n/zh/printer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ receipt:
discount:
label: 折扣
origin: 原單價
addOns:
label: 附加
adjustment: 調整金額
total: 總價
paid: 付額
price: 總價
Expand Down
19 changes: 8 additions & 11 deletions lib/components/imageable_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@ class ImageableContainer extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: kHorizontalSpacing, vertical: kTopSpacing),
child: SingleChildScrollView(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 600),
child: DefaultTextStyle(
style: const TextStyle(color: Color(0xFF424242)),
child: RepaintBoundary(
key: controller.key,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: children,
),
child: DefaultTextStyle(
style: const TextStyle(color: Color(0xFF424242), overflow: TextOverflow.clip),
child: RepaintBoundary(
key: controller.key,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: children,
),
),
),
Expand Down
16 changes: 6 additions & 10 deletions lib/components/models/order_attribute_value_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,22 @@ class OrderAttributeValueWidget {
return null;
}

final name = _name(mode, value);
final name = string(mode, value);
return name == '' ? HintText(S.orderAttributeValueEmpty) : Text(name);
}

static String _name(OrderAttributeMode mode, num value) {
static String string(OrderAttributeMode mode, num value) {
final modeValue = value;
if (mode == OrderAttributeMode.changeDiscount) {
final value = modeValue.toInt() / 100;
return value == 0
? S.orderAttributeValueFree
: value >= 1
? S.orderAttributeValueDiscountIncrease(value)
: S.orderAttributeValueDiscountDecrease(value);
final value = modeValue.toInt();
return value == 0 ? S.orderAttributeValueFree : 'x $value%';
} else {
final value = modeValue.toCurrency();
return modeValue == 0
? ''
: modeValue > 0
? S.orderAttributeValuePriceIncrease(value)
: S.orderAttributeValuePriceDecrease(value);
? '+ \$$value'
: '- \$$value';
}
}
}
43 changes: 5 additions & 38 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"@@locale": "en",
"@@last_modified": "2024-11-09T02:58:51.549087Z",
"@@author": "Lu Shueh Chou",
"settingTab": "Settings",
"settingVersion": "Version: {version}",
Expand Down Expand Up @@ -262,12 +261,14 @@
"printerSettingsMore": "More Settings Coming Soon!",
"printerReceiptTitle": "Receipt",
"printerReceiptColumnName": "Item",
"printerReceiptColumnPrice": "Unit",
"printerReceiptColumnCount": "Qty",
"printerReceiptColumnTotal": "Sub.",
"printerReceiptColumnPrice": "U/P",
"printerReceiptColumnCount": "QTY",
"printerReceiptColumnTotal": "TOT",
"printerReceiptColumnTime": "Time",
"printerReceiptDiscountLabel": "Discount",
"printerReceiptDiscountOrigin": "Origin",
"printerReceiptAddOnsLabel": "Add-Ons",
"printerReceiptAddOnsAdjustment": "ADJ",
"printerReceiptTotal": "Total",
"printerReceiptPaid": "Paid",
"printerReceiptPrice": "Price",
Expand Down Expand Up @@ -1323,40 +1324,6 @@
},
"orderAttributeValueEmpty": "No price impact",
"orderAttributeValueFree": "Free",
"orderAttributeValueDiscountIncrease": "Increase to {value} times",
"@orderAttributeValueDiscountIncrease": {
"placeholders": {
"value": {
"type": "num",
"format": "decimalPattern"
}
}
},
"orderAttributeValueDiscountDecrease": "Decrease to {value} times",
"@orderAttributeValueDiscountDecrease": {
"placeholders": {
"value": {
"type": "num",
"format": "decimalPattern"
}
}
},
"orderAttributeValuePriceIncrease": "Increase by {value} dollars",
"@orderAttributeValuePriceIncrease": {
"placeholders": {
"value": {
"type": "String"
}
}
},
"orderAttributeValuePriceDecrease": "Decrease by {value} dollars",
"@orderAttributeValuePriceDecrease": {
"placeholders": {
"value": {
"type": "String"
}
}
},
"menuTitle": "Menu",
"menuSubtitle": "Categories, Products",
"menuTutorialTitle": "Create Your Menu",
Expand Down
37 changes: 2 additions & 35 deletions lib/l10n/app_zh.arb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"@@locale": "zh",
"@@last_modified": "2024-11-09T02:58:51.627553Z",
"@@author": "Lu Shueh Chou",
"settingTab": "設定",
"settingVersion": "版本:{version}",
Expand Down Expand Up @@ -268,6 +267,8 @@
"printerReceiptColumnTime": "時間",
"printerReceiptDiscountLabel": "折扣",
"printerReceiptDiscountOrigin": "原單價",
"printerReceiptAddOnsLabel": "附加",
"printerReceiptAddOnsAdjustment": "調整金額",
"printerReceiptTotal": "總價",
"printerReceiptPaid": "付額",
"printerReceiptPrice": "總價",
Expand Down Expand Up @@ -1323,40 +1324,6 @@
},
"orderAttributeValueEmpty": "不影響價錢",
"orderAttributeValueFree": "免費",
"orderAttributeValueDiscountIncrease": "增加至 {value} 倍",
"@orderAttributeValueDiscountIncrease": {
"placeholders": {
"value": {
"type": "num",
"format": "decimalPattern"
}
}
},
"orderAttributeValueDiscountDecrease": "減少至 {value} 倍",
"@orderAttributeValueDiscountDecrease": {
"placeholders": {
"value": {
"type": "num",
"format": "decimalPattern"
}
}
},
"orderAttributeValuePriceIncrease": "增加 {value} 元",
"@orderAttributeValuePriceIncrease": {
"placeholders": {
"value": {
"type": "String"
}
}
},
"orderAttributeValuePriceDecrease": "減少 {value} 元",
"@orderAttributeValuePriceDecrease": {
"placeholders": {
"value": {
"type": "String"
}
}
},
"menuTitle": "菜單",
"menuSubtitle": "產品種類、產品",
"menuTutorialTitle": "建立屬於你的菜單",
Expand Down
44 changes: 21 additions & 23 deletions lib/ui/order/widgets/checkout_receipt_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,31 @@ class _CheckoutReceiptDialogState extends State<CheckoutReceiptDialog> {
Widget build(BuildContext context) {
return AlertDialog.adaptive(
contentPadding: const EdgeInsets.all(0),
content: Stack(
children: [
Padding(
padding: const EdgeInsets.only(
left: 24.0,
top: 16,
right: 24.0,
bottom: 24.0,
),
child: PrinterReceiptView(
controller: controller,
order: widget.order,
),
content: Stack(alignment: Alignment.center, children: [
Padding(
padding: const EdgeInsets.only(
left: 24.0,
top: 16,
right: 24.0,
bottom: 24.0,
),
child: PrinterReceiptView(
controller: controller,
order: widget.order,
),
Positioned.fill(
child: AbsorbPointer(
child: DecoratedBox(
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.35),
borderRadius: BorderRadius.circular(28),
),
child: const Center(child: CircularProgressIndicator.adaptive()),
),
Positioned.fill(
child: AbsorbPointer(
child: DecoratedBox(
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.35),
borderRadius: BorderRadius.circular(28),
),
child: const Center(child: CircularProgressIndicator.adaptive()),
),
),
],
),
),
]),
);
}

Expand Down
Loading

0 comments on commit 7132dcb

Please sign in to comment.