Skip to content

Commit

Permalink
Batch Check-in (#162)
Browse files Browse the repository at this point in the history
* feat: add batch check-in feature

- add fab entry in edit mode on display page
- add new page with responsive layout
- move some page widgets to common folder
- add l10n

* fix: disable refresh indicator on edit mode
  • Loading branch information
FriesI23 authored Apr 17, 2024
1 parent 6ea1f64 commit 8ed6001
Show file tree
Hide file tree
Showing 50 changed files with 2,855 additions and 194 deletions.
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"ymotongpoo.licenser",
"maptz.regionfolder",
"ryanluker.vscode-coverage-gutters",
"flutterando.flutter-coverage"
"flutterando.flutter-coverage",
"google.arb-editor"
]
}
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
"editor.wordBasedSuggestions": "off"
},
"[json]": {
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.formatOnSave": false,
"editor.formatOnType": false,
"editor.indentSize": 2
},
"[xml]": {
"editor.wordWrap": "off",
"editor.tabSize": 4
}
},
}
107 changes: 106 additions & 1 deletion assets/l10n/_untranslated.json
Original file line number Diff line number Diff line change
@@ -1 +1,106 @@
{}
{
"ar": [
"batchCheckin_appbar_title",
"batchCheckin_datePicker_prevButton_tooltip",
"batchCheckin_datePicker_nextButton_tooltip",
"batchCheckin_status_skip_text",
"batchCheckin_status_ok_text",
"batchCheckin_status_double_text",
"batchCheckin_status_zero_text",
"batchCheckin_habits_groupTitle",
"batchCheckin_save_button_text",
"batchCheckin_reset_button_text",
"batchCheckin_save_confirmDialog_title",
"batchCheckin_save_confirmDialog_body",
"batchCheckin_save_confirmDialog_confirmButton_text",
"batchCheckin_save_confirmDialog_cancelButton_text",
"batchCheckin_close_confirmDialog_title",
"batchCheckin_close_confirmDialog_body",
"batchCheckin_close_confirmDialog_confirmButton_text",
"batchCheckin_close_confirmDialog_cancelButton_text"
],

"de": [
"batchCheckin_appbar_title",
"batchCheckin_datePicker_prevButton_tooltip",
"batchCheckin_datePicker_nextButton_tooltip",
"batchCheckin_status_skip_text",
"batchCheckin_status_ok_text",
"batchCheckin_status_double_text",
"batchCheckin_status_zero_text",
"batchCheckin_habits_groupTitle",
"batchCheckin_save_button_text",
"batchCheckin_reset_button_text",
"batchCheckin_save_confirmDialog_title",
"batchCheckin_save_confirmDialog_body",
"batchCheckin_save_confirmDialog_confirmButton_text",
"batchCheckin_save_confirmDialog_cancelButton_text",
"batchCheckin_close_confirmDialog_title",
"batchCheckin_close_confirmDialog_body",
"batchCheckin_close_confirmDialog_confirmButton_text",
"batchCheckin_close_confirmDialog_cancelButton_text"
],

"fa": [
"batchCheckin_appbar_title",
"batchCheckin_datePicker_prevButton_tooltip",
"batchCheckin_datePicker_nextButton_tooltip",
"batchCheckin_status_skip_text",
"batchCheckin_status_ok_text",
"batchCheckin_status_double_text",
"batchCheckin_status_zero_text",
"batchCheckin_habits_groupTitle",
"batchCheckin_save_button_text",
"batchCheckin_reset_button_text",
"batchCheckin_save_confirmDialog_title",
"batchCheckin_save_confirmDialog_body",
"batchCheckin_save_confirmDialog_confirmButton_text",
"batchCheckin_save_confirmDialog_cancelButton_text",
"batchCheckin_close_confirmDialog_title",
"batchCheckin_close_confirmDialog_body",
"batchCheckin_close_confirmDialog_confirmButton_text",
"batchCheckin_close_confirmDialog_cancelButton_text"
],

"fr": [
"batchCheckin_appbar_title",
"batchCheckin_datePicker_prevButton_tooltip",
"batchCheckin_datePicker_nextButton_tooltip",
"batchCheckin_status_skip_text",
"batchCheckin_status_ok_text",
"batchCheckin_status_double_text",
"batchCheckin_status_zero_text",
"batchCheckin_habits_groupTitle",
"batchCheckin_save_button_text",
"batchCheckin_reset_button_text",
"batchCheckin_save_confirmDialog_title",
"batchCheckin_save_confirmDialog_body",
"batchCheckin_save_confirmDialog_confirmButton_text",
"batchCheckin_save_confirmDialog_cancelButton_text",
"batchCheckin_close_confirmDialog_title",
"batchCheckin_close_confirmDialog_body",
"batchCheckin_close_confirmDialog_confirmButton_text",
"batchCheckin_close_confirmDialog_cancelButton_text"
],

"vi": [
"batchCheckin_appbar_title",
"batchCheckin_datePicker_prevButton_tooltip",
"batchCheckin_datePicker_nextButton_tooltip",
"batchCheckin_status_skip_text",
"batchCheckin_status_ok_text",
"batchCheckin_status_double_text",
"batchCheckin_status_zero_text",
"batchCheckin_habits_groupTitle",
"batchCheckin_save_button_text",
"batchCheckin_reset_button_text",
"batchCheckin_save_confirmDialog_title",
"batchCheckin_save_confirmDialog_body",
"batchCheckin_save_confirmDialog_confirmButton_text",
"batchCheckin_save_confirmDialog_cancelButton_text",
"batchCheckin_close_confirmDialog_title",
"batchCheckin_close_confirmDialog_body",
"batchCheckin_close_confirmDialog_confirmButton_text",
"batchCheckin_close_confirmDialog_cancelButton_text"
]
}
29 changes: 29 additions & 0 deletions assets/l10n/en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,35 @@
},
"appAbout_donateDialog_copiedCrypto_msg": "Copied {name}'s Address",

"batchCheckin_appbar_title": "Batch Check-in",
"batchCheckin_datePicker_prevButton_tooltip": "Previous day",
"batchCheckin_datePicker_nextButton_tooltip": "Next day",
"batchCheckin_status_skip_text": "Skip",
"batchCheckin_status_ok_text": "Complete",
"batchCheckin_status_double_text": "x2 Hit!",
"batchCheckin_status_zero_text": "Incomplete",
"@batchCheckin_habits_groupTitle": {
"placeholders": {
"count": {
"type": "int",
"example": "1"
}
}
},
"batchCheckin_habits_groupTitle": "{count} {count, plural, =1{Habit} other{Habits}} selected",
"batchCheckin_save_button_text": "Save",
"batchCheckin_reset_button_text": "Reset",

"batchCheckin_save_confirmDialog_title": "Overwrite Existing Records",
"batchCheckin_save_confirmDialog_body": "Existing records will be overwritten After saving, previous records will be lost.",
"batchCheckin_save_confirmDialog_confirmButton_text": "save",
"batchCheckin_save_confirmDialog_cancelButton_text": "cancel",

"batchCheckin_close_confirmDialog_title": "Confirm Return",
"batchCheckin_close_confirmDialog_body": "Check-in Status Changes won't be applied before saved",
"batchCheckin_close_confirmDialog_confirmButton_text": "exit",
"batchCheckin_close_confirmDialog_cancelButton_text": "cancel",

"appReminder_dailyReminder_title": "🏝 Did you stick to your habits today?",
"appReminder_dailyReminder_body": "click to enter app and punch in on time.",

Expand Down
20 changes: 19 additions & 1 deletion assets/l10n/zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -589,5 +589,23 @@
"userAction_doubleTap": "双击",
"@userAction_doubleTap": {},
"userAction_longTap": "长按",
"@userAction_longTap": {}
"@userAction_longTap": {},
"batchCheckin_appbar_title": "批量打卡",
"batchCheckin_datePicker_prevButton_tooltip": "前一天",
"batchCheckin_datePicker_nextButton_tooltip": "后一天",
"batchCheckin_status_skip_text": "跳过",
"batchCheckin_status_ok_text": "完成",
"batchCheckin_status_double_text": "超量完成",
"batchCheckin_status_zero_text": "未完成",
"batchCheckin_habits_groupTitle": "已选择{count}个习惯}",
"batchCheckin_save_button_text": "保存",
"batchCheckin_reset_button_text": "重置",
"batchCheckin_save_confirmDialog_title": "覆盖现有记录",
"batchCheckin_save_confirmDialog_body": "保存后将覆盖现有记录,之前记录将丢失。",
"batchCheckin_save_confirmDialog_confirmButton_text": "保存",
"batchCheckin_save_confirmDialog_cancelButton_text": "取消",
"batchCheckin_close_confirmDialog_title": "确认返回",
"batchCheckin_close_confirmDialog_body": "未保存的打卡状态更改将不会生效。",
"batchCheckin_close_confirmDialog_confirmButton_text": "确认",
"batchCheckin_close_confirmDialog_cancelButton_text": "取消"
}
8 changes: 7 additions & 1 deletion lib/common/consts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.
// coverage:ignore-file

import 'dart:ui';
import 'package:flutter/material.dart';

import '../model/app_reminder_config.dart';
import '../model/habit_display.dart';
Expand Down Expand Up @@ -118,4 +118,10 @@ const skipReasonChipTextList = [
'😕',
'😠',
];

const kRecordAutoMarkStatusIcon = Icons.done_outline;
const kRecordUnknownStatusIcon = Icons.question_mark_outlined;
const kRecordSkipStatusIcon = Icons.remove_outlined;
const kRecordDoneStatusIcon = Icons.check_outlined;
const kRecordZeroStatusIcon = Icons.close_sharp;
//#endregion
7 changes: 7 additions & 0 deletions lib/common/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import 'package:url_launcher/url_launcher.dart' as url_launcher;
import 'package:url_launcher/url_launcher_string.dart';
import 'package:uuid/uuid.dart';

import '../extension/datetime_extensions.dart';
import '../logging/level.dart';
import '../theme/color.dart';
import 'consts.dart';
Expand Down Expand Up @@ -221,3 +222,9 @@ LogLevel getDefaultLogLevel() {
return LogLevel.debug;
}
}

T stampDateTime<T extends DateTime>(T t, {required T max, required T min}) {
t = t > max ? max : t;
t = t < min ? min : t;
return t;
}
4 changes: 3 additions & 1 deletion lib/component/widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import 'package:flutter/material.dart' show EdgeInsets;
import 'package:flutter/material.dart' show EdgeInsets, EdgeInsetsDirectional;

export './widgets/chip_list.dart';
export './widgets/color_display_chip.dart';
Expand Down Expand Up @@ -43,3 +43,5 @@ export './widgets/week_picker_cell.dart';

const kExpanedDailogInsetPadding =
EdgeInsets.only(left: 40.0, right: 40.0, bottom: 10.0);
const kListTileContentPadding =
EdgeInsetsDirectional.only(start: 16.0, end: 24.0);
11 changes: 6 additions & 5 deletions lib/component/widgets/habit_daily_status_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';

import '../../common/consts.dart';
import '../../common/types.dart';
import '../../extension/colorscheme_extensions.dart';
import '../../extension/custom_color_extensions.dart';
Expand Down Expand Up @@ -68,7 +69,7 @@ class HabitDailyStatusContainer extends StatelessWidget {

Widget withAutoMarkStatus() {
return Icon(
Icons.done_outline,
kRecordAutoMarkStatusIcon,
color: habitListTileColor?.dailyStatusTheme?.autoMark ??
globalColor?.autoMark ??
defaultColor.autoMark,
Expand All @@ -77,7 +78,7 @@ class HabitDailyStatusContainer extends StatelessWidget {

Widget withUnknownStatus() {
return Icon(
Icons.question_mark_outlined,
kRecordUnknownStatusIcon,
color: habitListTileColor?.dailyStatusTheme?.unknown ??
globalColor?.unknown ??
defaultColor.unknown,
Expand All @@ -86,7 +87,7 @@ class HabitDailyStatusContainer extends StatelessWidget {

Widget withSkipStatus() {
return Icon(
Icons.remove_outlined,
kRecordSkipStatusIcon,
color: habitListTileColor?.dailyStatusTheme?.skip ??
globalColor?.skip ??
defaultColor.skip,
Expand All @@ -95,7 +96,7 @@ class HabitDailyStatusContainer extends StatelessWidget {

Widget withDoneAndOkStatus() {
return Icon(
Icons.check_outlined,
kRecordDoneStatusIcon,
color: habitListTileColor?.dailyStatusTheme?.doneAndOk ??
globalColor?.doneAndOk ??
defaultColor.doneAndOk,
Expand All @@ -104,7 +105,7 @@ class HabitDailyStatusContainer extends StatelessWidget {

Widget withDoneAndZeroStatus() {
return Icon(
Icons.close_sharp,
kRecordZeroStatusIcon,
color: habitListTileColor?.dailyStatusTheme?.doneAndZero ??
globalColor?.doneAndZero ??
defaultColor.doneAndZero,
Expand Down
2 changes: 1 addition & 1 deletion lib/component/widgets/habit_list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class HabitListTile extends StatelessWidget {
this.backgroundColor,
this.padding,
this.scrollPhysicsBuilder,
}) : assert(sizePrt > 0 && sizePrt < 1);
}) : assert(sizePrt >= 0 && sizePrt < 1);

static int calcLimitItemCount(
double maxWidth, double maxHeight, double sizePrt,
Expand Down
Loading

0 comments on commit 8ed6001

Please sign in to comment.