Skip to content

Commit

Permalink
fix: correct from UI test
Browse files Browse the repository at this point in the history
  • Loading branch information
evan361425 committed Sep 16, 2024
1 parent 32d4571 commit 84ad38d
Show file tree
Hide file tree
Showing 29 changed files with 231 additions and 149 deletions.
4 changes: 2 additions & 2 deletions assets/l10n/en/order.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ checkout:
name: order
attribute:
tab: Customer
cashier:
tab: Checkout
details:
tab: Details
calculator:
label:
paid: Paid
Expand Down
3 changes: 2 additions & 1 deletion assets/l10n/en/transit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ GS:
- name:
exist:
label:
- Specify & Export
- Export
- Inform the user that data will be exported to the specified spreadsheet.
hint:
- Export to spreadsheet "{name}"
Expand All @@ -136,6 +136,7 @@ GS:
empty:
label: Select Spreadsheet
hint: Once you choose the spreadsheet to import, you can start importing data.
dropdownHint: Sheet to Import
confirm:
- This action will {hint}
- hint:
Expand Down
4 changes: 2 additions & 2 deletions assets/l10n/zh/order.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ checkout:
name: 訂單
attribute:
tab: 顧客設定
cashier:
tab: 收銀機
details:
tab: 訂單細項
calculator:
label:
paid: 付額
Expand Down
1 change: 1 addition & 0 deletions assets/l10n/zh/transit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ GS:
empty:
label: 選擇試算表
hint: 選擇要匯入的試算表後,就能開始匯入資料
dropdownHint: 匯入的表單
confirm: 此動作將會{hint}
selectionHint:
- _: 輸入試算表網址或試算表 ID
Expand Down
14 changes: 9 additions & 5 deletions lib/components/item_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,22 @@ class ItemLoaderState<T, U> extends State<ItemLoader<T, U>> {
key: const Key('item_loader'),
prototypeItem: widget.leading == null ? widget.prototypeItem : null,
itemBuilder: (context, index) {
// leading is always the first item
if (widget.leading != null) {
if (index == 0) {
return widget.leading!;
}
index--;
}

if (index == 0) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: widget.metricsBuilder(metrics as U),
);
}

if (widget.leading != null && index == 1) {
return widget.leading!;
}

index = widget.leading == null ? index - 1 : index - 2;
index--;
// loading over the size
if (items.length == index) {
if (isFinish) {
Expand Down
39 changes: 21 additions & 18 deletions lib/components/slidable_item_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,42 @@ class SlidableItemList<T, Action> extends StatelessWidget {
final SlidableItemDelegate<T, Action> delegate;
final String? hintText;
final Widget? leading;
final Widget? tailing;
final Widget? action;

const SlidableItemList({
super.key,
required this.delegate,
this.hintText,
this.leading,
this.tailing,
this.action,
});

@override
Widget build(BuildContext context) {
return SingleChildScrollView(
padding: const EdgeInsets.only(top: kTopSpacing, bottom: kFABSpacing),
child: Column(children: <Widget>[
if (leading != null) leading!,
Row(children: [
Expanded(child: Center(child: HintText(hintText ?? S.totalCount(delegate.items.length)))),
if (action != null)
return Material(
child: SingleChildScrollView(
padding: const EdgeInsets.only(top: kTopSpacing, bottom: kFABSpacing),
child: Column(children: <Widget>[
if (leading != null)
Padding(
padding: const EdgeInsets.only(right: kHorizontalSpacing),
child: action,
padding: const EdgeInsets.symmetric(horizontal: kHorizontalSpacing),
child: leading!,
),
Row(children: [
Expanded(child: Center(child: HintText(hintText ?? S.totalCount(delegate.items.length)))),
if (action != null)
Padding(
padding: const EdgeInsets.only(right: kHorizontalSpacing),
child: action,
),
]),
const SizedBox(height: kInternalSpacing),
for (final widget in delegate.items.mapIndexed(
(index, item) => delegate.build(item, index),
))
widget,
]),
const SizedBox(height: kInternalSpacing),
for (final widget in delegate.items.mapIndexed(
(index, item) => delegate.build(item, index),
))
widget,
if (tailing != null) tailing!,
]),
),
);
}
}
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 Wrap(alignment: WrapAlignment.center, children: [
return Wrap(alignment: WrapAlignment.center, crossAxisAlignment: WrapCrossAlignment.center, children: [
TextButton(
onPressed: _links[0].launch,
child: Text(_links[0].text),
Expand Down
5 changes: 3 additions & 2 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-11T08:15:55.169432Z",
"@@last_modified": "2024-09-14T13:02:19.109593Z",
"@@author": "Lu Shueh Chou",
"settingTab": "Settings",
"settingVersion": "Version: {version}",
Expand Down Expand Up @@ -367,7 +367,7 @@
}
}
},
"transitGSSpreadsheetExportExistLabel": "Specify & Export",
"transitGSSpreadsheetExportExistLabel": "Export",
"@transitGSSpreadsheetExportExistLabel": {
"description": "Inform the user that data will be exported to the specified spreadsheet."
},
Expand All @@ -387,6 +387,7 @@
"transitGSSpreadsheetImportExistHint": "Get all sheet names from the spreadsheet and ready to import.",
"transitGSSpreadsheetImportEmptyLabel": "Select Spreadsheet",
"transitGSSpreadsheetImportEmptyHint": "Once you choose the spreadsheet to import, you can start importing data.",
"transitGSSpreadsheetImportDropdownHint": "Sheet to Import",
"transitGSSpreadsheetConfirm": "This action will {hint}",
"@transitGSSpreadsheetConfirm": {
"placeholders": {
Expand Down
3 changes: 2 additions & 1 deletion 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-11T08:15:55.195501Z",
"@@last_modified": "2024-09-14T13:02:19.146195Z",
"@@author": "Lu Shueh Chou",
"settingTab": "設定",
"settingVersion": "版本:{version}",
Expand Down Expand Up @@ -387,6 +387,7 @@
"transitGSSpreadsheetImportExistHint": "從試算表中取得所有表單的名稱,並進行匯入",
"transitGSSpreadsheetImportEmptyLabel": "選擇試算表",
"transitGSSpreadsheetImportEmptyHint": "選擇要匯入的試算表後,就能開始匯入資料",
"transitGSSpreadsheetImportDropdownHint": "匯入的表單",
"transitGSSpreadsheetConfirm": "此動作將會{hint}",
"@transitGSSpreadsheetConfirm": {
"placeholders": {
Expand Down
15 changes: 8 additions & 7 deletions lib/ui/analysis/analysis_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ class _AnalysisViewState extends State<AnalysisView> with AutomaticKeepAliveClie
final bp = Breakpoint.find(box: constraints);
return CustomScrollView(slivers: <Widget>[
child!,
SliverAppBar(primary: false, title: Text(S.analysisChartTitle), actions: const [
_MoreButton(),
]),
SliverAppBar(
primary: false,
automaticallyImplyLeading: false, // avoid giving drawer's menu icon
title: Text(S.analysisChartTitle), actions: const [_MoreButton()],
),
_buildChartHeader(),
_buildCharts(Analysis.instance.itemList, bp),
]);
Expand Down Expand Up @@ -87,17 +89,16 @@ class _AnalysisViewState extends State<AnalysisView> with AutomaticKeepAliveClie
}

Widget _buildCharts(List<Chart> items, Breakpoint bp) {
final col = bp.lookup<int>(compact: 1, medium: 2, expanded: 3, large: 4);
return SliverPadding(
padding: const EdgeInsets.only(bottom: kFABSpacing),
sliver: SliverGrid.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: bp.lookup<int>(expanded: 2, large: 3, compact: 1),
),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: col),
itemCount: items.length + 1,
itemBuilder: (context, index) {
if (index == items.length) {
return Align(
alignment: Alignment.topCenter,
alignment: col == 1 ? Alignment.topCenter : Alignment.center,
child: SizedBox(
width: 200,
height: 200,
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/analysis/history_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class _HistoryPageState extends State<HistoryPage> {

@override
Widget build(BuildContext context) {
final singleView = MediaQuery.sizeOf(context).width <= Breakpoint.medium.max;
return TutorialWrapper(
child: Scaffold(
appBar: AppBar(
Expand Down Expand Up @@ -57,7 +58,7 @@ class _HistoryPageState extends State<HistoryPage> {
),
],
),
body: MediaQuery.sizeOf(context).width <= Breakpoint.medium.max ? _buildSingleColumn() : _buildTwoColumns(),
body: singleView ? _buildSingleColumn() : _buildTwoColumns(),
),
);
}
Expand Down
4 changes: 3 additions & 1 deletion lib/ui/analysis/widgets/goals_card_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ class _GoalsCardViewState extends State<GoalsCardView> {
);

// Remove the first data, which is the latest data.
final todayData = result.firstOrNull?.at == range.end ? result.removeAt(0) : OrderSummary(at: range.start);
final todayData = result.firstOrNull?.at == range.end.subtract(const Duration(days: 1))
? result.removeAt(0)
: OrderSummary(at: range.start);

if (goal == null) {
final reversed = result.take(20).toList().reversed;
Expand Down
17 changes: 13 additions & 4 deletions lib/ui/analysis/widgets/history_calendar_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:collection';
import 'package:flutter/material.dart';
import 'package:possystem/helpers/util.dart';
import 'package:possystem/models/repository/seller.dart';
import 'package:possystem/services/cache.dart';
import 'package:possystem/settings/language_setting.dart';
import 'package:possystem/translator.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -34,7 +35,7 @@ class _HistoryCalendarViewState extends State<HistoryCalendarView> {
hashCode: _hashDate,
);

CalendarFormat _calendarFormat = CalendarFormat.week;
late CalendarFormat _calendarFormat;

late DateTime _selectedDay;

Expand Down Expand Up @@ -74,17 +75,25 @@ class _HistoryCalendarViewState extends State<HistoryCalendarView> {
defaultBuilder: _defaultBuilder,
),
onPageChanged: _searchPageData,
onFormatChanged: (format) => setState(() => _calendarFormat = format),
onFormatChanged: (format) async {
setState(() => _calendarFormat = format);
await Cache.instance.set('history.calendar_format', format.index);
},
onDaySelected: (DateTime selectedDay, DateTime focusedDay) => _onDaySelected(selectedDay),
),
);
}

@override
void initState() {
super.initState();

_focusedDay = _selectedDay = widget.notifier.value.start;

// cache from last time, or default to month if in wide screen else week
final cached = Cache.instance.get<int>('history.calendar_format') ?? CalendarFormat.values.length;
_calendarFormat = CalendarFormat.values.elementAtOrNull(cached) ??
(widget.shouldFillViewport ? CalendarFormat.month : CalendarFormat.week);

super.initState();
}

@override
Expand Down
36 changes: 20 additions & 16 deletions lib/ui/image_gallery_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,33 +108,37 @@ class ImageGalleryPageState extends State<ImageGalleryPage> {
}

final spacing = bp.lookup(compact: 4.0, expanded: 12.0);
// maximum width is 800
final crossAxisCount = bp.lookup(compact: 3, medium: 4);
return GridView.builder(
primary: false,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: bp.lookup(compact: 3, expanded: 4),
crossAxisCount: crossAxisCount,
crossAxisSpacing: spacing,
mainAxisSpacing: spacing,
),
// add 1 for add button, add crossAxisCount for spacing
itemCount: images!.length + (selecting ? 0 : 1) + 3,
// add 1 for add button, and add crossAxisCount for bottom spacing
itemCount: images!.length + (selecting ? 0 : 1) + crossAxisCount,
semanticChildCount: images!.length,
itemBuilder: (context, index) {
if (!selecting && index == images!.length) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: ElevatedButton(
key: const Key('image_gallery.add'),
onPressed: createImage,
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
const Icon(KIcons.add),
Text(S.imageGalleryActionCreate, textAlign: TextAlign.center),
]),
),
);
if (!selecting) {
if (index == 0) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: ElevatedButton(
key: const Key('image_gallery.add'),
onPressed: createImage,
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
const Icon(KIcons.add),
Text(S.imageGalleryActionCreate, textAlign: TextAlign.center),
]),
),
);
}
index--; // remove 0-index of add button
}

if (index >= images!.length) {
// Floating action button offset
return const SizedBox(height: kFABSpacing);
}

Expand Down
Loading

0 comments on commit 84ad38d

Please sign in to comment.