Skip to content

Commit

Permalink
fix all test
Browse files Browse the repository at this point in the history
  • Loading branch information
evan361425 committed Sep 11, 2024
1 parent a234f78 commit 87c0f33
Show file tree
Hide file tree
Showing 32 changed files with 1,142 additions and 1,038 deletions.
7 changes: 4 additions & 3 deletions assets/l10n/en/global.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ title:
- analysis: Stats
stock: Inventory
cashier: Cashier
setting: Settings
settings: Settings
menu: Menu
transit: Data Transfer
orderAttribute: Customer Settings
stockQuantity: Quantities
orderAttributes: Customer Settings
stockQuantities: Quantities
elf: Suggestions
more: More
debug: Debug
dialog:
deletionTitle:
- Delete Confirmation
Expand Down
2 changes: 1 addition & 1 deletion assets/l10n/en/order_attribute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ headerInfo:
- Customer Settings
- Displayed on the upper rectangle in homepage
tutorial:
title: Customer Settings
title: Create Your Customer Settings
content: |-
This is where you set customer information, such as dine-in, takeout, office worker, etc.
This information helps us track who comes to consume and make better business strategies.
Expand Down
7 changes: 4 additions & 3 deletions assets/l10n/zh/global.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ title:
- analysis: 分析
stock: 庫存
cashier: 收銀
setting: 設定
settings: 設定
menu: 菜單
transit: 資料轉移
orderAttribute: 顧客設定
stockQuantity: 份量
orderAttributes: 顧客設定
stockQuantities: 份量
elf: 建議
more: 更多
debug: Debug
dialog:
deletionTitle: 刪除確認通知
deletionContent: |-
Expand Down
2 changes: 1 addition & 1 deletion assets/l10n/zh/order_attribute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ emptyBody: |-
20-30歲、外帶、上班族。
headerInfo: 顧客設定
tutorial:
title: 顧客設定
title: 建立屬於你的顧客設定
content: |-
這裡是用來設定顧客的資訊,例如:內用、外帶、上班族等。
這些資訊可以幫助我們統計哪些人來消費,進而做出更好的經營策略。
Expand Down
23 changes: 7 additions & 16 deletions lib/components/bottom_sheet_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'dialog/delete_dialog.dart';
Future<T?> showCircularBottomSheet<T>(
BuildContext context, {
required List<BottomSheetAction<T>> actions,
bool useRootNavigator = true,
}) {
Feedback.forLongPress(context);
final size = MediaQuery.sizeOf(context);
Expand All @@ -17,7 +16,7 @@ Future<T?> showCircularBottomSheet<T>(
if (bp <= Breakpoint.medium) {
return showModalBottomSheet<T>(
context: context,
useRootNavigator: useRootNavigator,
useRootNavigator: true,
clipBehavior: Clip.hardEdge,
constraints: BoxConstraints(maxWidth: size.width - 24),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
Expand All @@ -44,7 +43,6 @@ Future<T?> showCircularBottomSheet<T>(
return showMenu(
context: context,
position: position,
useRootNavigator: useRootNavigator,
clipBehavior: Clip.hardEdge,
items: [
for (final action in actions) action.toPopupMenuItem(context),
Expand All @@ -55,7 +53,7 @@ Future<T?> showCircularBottomSheet<T>(
class BottomSheetAction<T> {
final Widget title;

final Widget? leading;
final Widget leading;

final T? returnValue;

Expand All @@ -68,9 +66,9 @@ class BottomSheetAction<T> {
final Map<String, dynamic> routeQueryParameters;

const BottomSheetAction({
required this.title,
this.key,
this.leading,
required this.title,
required this.leading,
this.returnValue,
this.route,
this.routePathParameters = const <String, String>{},
Expand All @@ -87,7 +85,7 @@ class BottomSheetAction<T> {
if (context.mounted) {
Navigator.of(context).pop(returnValue);
}
onTap(context);
await onTap(context);
},
);
}
Expand All @@ -97,18 +95,11 @@ class BottomSheetAction<T> {
key: key,
value: returnValue,
onTap: () => onTap(context),
child: Row(children: [
if (leading != null)
Padding(
padding: const EdgeInsets.only(right: 8),
child: leading!,
),
title,
]),
child: ListTile(leading: leading, title: title),
);
}

void onTap(BuildContext context) async {
Future<void> onTap(BuildContext context) async {
if (route != null && context.mounted) {
await context.pushNamed(
route!,
Expand Down
5 changes: 4 additions & 1 deletion lib/components/dialog/responsive_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ class ResponsiveDialog extends StatelessWidget {
actions: action == null
? null
: [
PopButton(title: MaterialLocalizations.of(context).cancelButtonLabel),
PopButton(
key: const Key('pop'),
title: MaterialLocalizations.of(context).cancelButtonLabel,
),
action!,
],
);
Expand Down
8 changes: 2 additions & 6 deletions lib/components/linkify.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:possystem/helpers/launcher.dart';
import 'package:possystem/helpers/logger.dart';

final _regex = RegExp(r'\[([^\]]+)\]\((https?:\/\/[^\)]+)\)');

Expand All @@ -20,11 +19,8 @@ class Linkify extends StatelessWidget {
/// at new Linkify.fromString(linkify.dart:15)
/// at Tutorial.build(tutorial.dart:107)
/// ```
factory Linkify.fromString(String? text, {TextAlign? textAlign, String? id}) {
if (text == null) {
Log.err('Get null string id tutorial id: $id', 'linkify');
}
return Linkify(_parseText(text ?? ''), textAlign: textAlign);
factory Linkify.fromString(String text, {TextAlign? textAlign, String? id}) {
return Linkify(_parseText(text), textAlign: textAlign);
}

@override
Expand Down
1 change: 1 addition & 0 deletions lib/components/slivers/sliver_image_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class SliverImageAppBar extends StatelessWidget {
final background = ImageHolder(
image: model.image,
padding: const EdgeInsets.fromLTRB(0, 36, 0, 0),
// required for the gradient
title: '',
onImageError: () => model.saveImage(null),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/components/style/footer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Footer extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Row(mainAxisAlignment: MainAxisAlignment.center, children: [
return Wrap(alignment: WrapAlignment.center, children: [
TextButton(
onPressed: _links[0].launch,
child: Text(_links[0].text),
Expand Down
54 changes: 28 additions & 26 deletions lib/components/style/image_holder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:possystem/translator.dart';
class ImageHolder extends StatelessWidget {
final ImageProvider image;

final String title;
final String? title;

final void Function()? onPressed;

Expand All @@ -23,7 +23,7 @@ class ImageHolder extends StatelessWidget {
const ImageHolder({
super.key,
required this.image,
required this.title,
this.title,
this.size = 256,
this.onPressed,
this.onImageError,
Expand All @@ -37,30 +37,32 @@ class ImageHolder extends StatelessWidget {
final style = Theme.of(context).textTheme.bodyMedium;
final colors = [color, color.withAlpha(180), color.withAlpha(10)];

Widget body = Container(
width: double.infinity,
decoration: const BoxDecoration(border: Border()),
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
width: double.infinity,
padding: padding,
decoration: BoxDecoration(
border: Border(bottom: BorderSide(color: colors[0])),
gradient: LinearGradient(
colors: colors,
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
Widget body = title == null
? const SizedBox.expand()
: Container(
width: double.infinity,
decoration: const BoxDecoration(border: Border()),
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
width: double.infinity,
padding: padding,
decoration: BoxDecoration(
border: Border(bottom: BorderSide(color: colors[0])),
gradient: LinearGradient(
colors: colors,
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
),
),
child: Text(
title!,
textAlign: TextAlign.center,
style: style?.copyWith(fontWeight: FontWeight.bold),
),
),
),
),
child: Text(
title,
textAlign: TextAlign.center,
style: style?.copyWith(fontWeight: FontWeight.bold),
),
),
),
);
);

if (onPressed != null) {
body = InkWell(
Expand All @@ -82,7 +84,7 @@ class ImageHolder extends StatelessWidget {
image: image,
fit: BoxFit.cover,
onImageError: (error, stack) {
Log.err(error, 'image_holder_error', stack);
Log.err(error, 'image_error', stack);
onImageError?.call();
},
child: body,
Expand Down
20 changes: 6 additions & 14 deletions lib/components/style/route_buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import 'package:possystem/translator.dart';
class RouteElevatedIconButton extends StatelessWidget {
final Icon icon;

final String? route;

final String label;

final bool popTrueShowSuccess;
final String? route;

final Map<String, String> pathParameters;

Expand All @@ -22,7 +20,6 @@ class RouteElevatedIconButton extends StatelessWidget {
required this.icon,
required this.route,
required this.label,
this.popTrueShowSuccess = false,
this.pathParameters = const {},
this.queryParameters = const {},
});
Expand All @@ -32,16 +29,11 @@ class RouteElevatedIconButton extends StatelessWidget {
return ElevatedButton.icon(
icon: icon,
label: Text(label),
onPressed: () async {
final result = await context.pushNamed(
route!,
pathParameters: pathParameters,
queryParameters: queryParameters,
);
if (result == true && popTrueShowSuccess && context.mounted) {
showSnackBar(context, S.actSuccess);
}
},
onPressed: () => context.pushNamed(
route!,
pathParameters: pathParameters,
queryParameters: queryParameters,
),
);
}
}
Expand Down
6 changes: 3 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-09-01T08:25:33.606863Z",
"@@last_modified": "2024-09-11T07:30:16.339769Z",
"@@author": "Lu Shueh Chou",
"settingTab": "Settings",
"settingVersion": "Version: {version}",
Expand Down Expand Up @@ -993,7 +993,7 @@
}
}
},
"title": "{name, select, analysis{Stats} stock{Inventory} cashier{Cashier} setting{Settings} menu{Menu} transit{Data Transfer} orderAttribute{Customer Settings} stockQuantity{Quantities} elf{Suggestions} more{More} other{UNKNOWN}}",
"title": "{name, select, analysis{Stats} stock{Inventory} cashier{Cashier} settings{Settings} menu{Menu} transit{Data Transfer} orderAttributes{Customer Settings} stockQuantities{Quantities} elf{Suggestions} more{More} debug{Debug} other{UNKNOWN}}",
"dialogDeletionTitle": "Delete Confirmation",
"@dialogDeletionTitle": {
"description": "Title displayed on the DeleteDialog."
Expand Down Expand Up @@ -1149,7 +1149,7 @@
"@orderAttributeHeaderInfo": {
"description": "Displayed on the upper rectangle in homepage"
},
"orderAttributeTutorialTitle": "Customer Settings",
"orderAttributeTutorialTitle": "Create Your Customer Settings",
"orderAttributeTutorialContent": "This is where you set customer information, such as dine-in, takeout, office worker, etc.\nThis information helps us track who comes to consume and make better business strategies.",
"orderAttributeTutorialCreateExample": "Help create an example to test.",
"orderAttributeExampleAge": "Age",
Expand Down
6 changes: 3 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-09-01T08:25:33.632578Z",
"@@last_modified": "2024-09-11T07:30:16.362623Z",
"@@author": "Lu Shueh Chou",
"settingTab": "設定",
"settingVersion": "版本:{version}",
Expand Down Expand Up @@ -993,7 +993,7 @@
}
}
},
"title": "{name, select, analysis{分析} stock{庫存} cashier{收銀} setting{設定} menu{菜單} transit{資料轉移} orderAttribute{顧客設定} stockQuantity{份量} elf{建議} more{更多} other{UNKNOWN}}",
"title": "{name, select, analysis{分析} stock{庫存} cashier{收銀} settings{設定} menu{菜單} transit{資料轉移} orderAttributes{顧客設定} stockQuantities{份量} elf{建議} more{更多} debug{Debug} other{UNKNOWN}}",
"dialogDeletionTitle": "刪除確認通知",
"@dialogDeletionTitle": {
"description": "Title displayed on the DeleteDialog."
Expand Down Expand Up @@ -1149,7 +1149,7 @@
"@orderAttributeHeaderInfo": {
"description": "Displayed on the upper rectangle in homepage"
},
"orderAttributeTutorialTitle": "顧客設定",
"orderAttributeTutorialTitle": "建立屬於你的顧客設定",
"orderAttributeTutorialContent": "這裡是用來設定顧客的資訊,例如:內用、外帶、上班族等。\n這些資訊可以幫助我們統計哪些人來消費,進而做出更好的經營策略。",
"orderAttributeTutorialCreateExample": "幫助建立一份範例以供測試。",
"orderAttributeExampleAge": "年齡",
Expand Down
4 changes: 2 additions & 2 deletions lib/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ class Routes {
static get initLocation => Cache.instance.get<bool>('tutorial.home.order') != true
? homeMode.value == HomeMode.bottomNavigationBar
? '$base/_'
: '$base/_/menu'
: base;
: '$base/_/menu' // if going to anal, the tutorial will conflicts with analysis page's tutorial
: '$base/anal';

/// Base redirect function
///
Expand Down
7 changes: 5 additions & 2 deletions lib/ui/analysis/widgets/goals_card_view.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:possystem/components/style/info_popup.dart';
import 'package:possystem/constants/constant.dart';
import 'package:possystem/helpers/analysis/ema_calculator.dart';
import 'package:possystem/helpers/breakpoint.dart';
import 'package:possystem/helpers/util.dart';
import 'package:possystem/models/repository/seller.dart';
import 'package:possystem/services/cache.dart';
Expand Down Expand Up @@ -58,7 +60,7 @@ class _GoalsCardViewState extends State<GoalsCardView> {
final style = Theme.of(context).textTheme.bodyLarge?.copyWith(overflow: TextOverflow.ellipsis);

return LayoutBuilder(builder: (context, constraint) {
final compact = constraint.maxWidth < 600;
final compact = constraint.maxWidth < Breakpoint.compact.max;
final align = goal!.profit == 0 ? MainAxisAlignment.start : MainAxisAlignment.spaceAround;
return Row(mainAxisAlignment: align, children: [
Column(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
Expand Down Expand Up @@ -216,7 +218,8 @@ class _GoalItem extends StatelessWidget {
constraints: const BoxConstraints(maxWidth: 320),
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
label,
Expanded(child: value),
const SizedBox(width: kInternalLargeSpacing),
Expanded(child: Align(alignment: Alignment.centerRight, child: value)),
]),
);
}
Expand Down
Loading

0 comments on commit 87c0f33

Please sign in to comment.