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

Feature/#99 #120

Merged
merged 6 commits into from
Dec 17, 2023
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
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.suggestSelection": "first",
"editor.tabCompletion": "onlySnippets",
"editor.wordBasedSuggestions": false
"editor.wordBasedSuggestions": "off"
},
"[json]": {
"editor.formatOnSave": true,
Expand Down
7 changes: 7 additions & 0 deletions assets/l10n/_untranslated.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"de": [
"appSetting_changeRecordStatusOpTile_subtitleText",
"appSetting_openRecordStatusDialogOpTile_subtitleText"
],

"fa": [
"habitDisplay_editPopMenu_clone",
"habitDetail_editPopMenu_clone",
"appSetting_changeRecordStatusOpTile_subtitleText",
"appSetting_openRecordStatusDialogOpTile_subtitleText",
"appSetting_clearCache_titleText",
"appSetting_clearCacheDialog_titleText",
"appSetting_clearCacheDialog_subtitleText",
Expand Down
9 changes: 8 additions & 1 deletion assets/l10n/de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,11 @@
"appSetting_appbar_titleText": "Einstellungen",

"appSetting_displaySubgroupText": "Anzeige",
"appSetting_operationSubgroupText": "Bedienen",
"appSetting_dragCalendarByPageTile_titleText": "Kalender nach Seite ziehen",
"appSetting_dragCalendarByPageTile_subtitleText": "Wenn der Schalter aktiviert ist, wird der Balkenkalender der App auf der Startseite Seite für Seiten gezogen. Standardmäßig ist diese Funktion deaktiviert.",
"appSetting_changeRecordStatusOpTile_titleText": "Status ändern",
"appSetting_openRecordStatusDialogOpTile_titleText": "Detaillierte Aufzeichnung öffnen",
"appSetting_firstDayOfWeek_titleText": "Erster Tag der Woche",
"appSetting_firstDayOfWeekDialog_titleText": "Ersten Tag der Woche auswählen",
"appSetting_firstDayOfWeekDialog_defaultText": " (Standard)",
Expand Down Expand Up @@ -655,5 +658,9 @@
"exportConfirmDialog_confirm_buttonText": "Exportieren",

"snackbar_undoText": "Rückgängig",
"snackbar_dissmessText": "Ablehnen"
"snackbar_dissmessText": "Ablehnen",

"userAction_tap": "Tippen",
"userAction_doubleTap": "Doppel",
"userAction_longTap": "Lang"
}
11 changes: 10 additions & 1 deletion assets/l10n/en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,13 @@
"appSetting_appbar_titleText": "Settings",

"appSetting_displaySubgroupText": "Display",
"appSetting_operationSubgroupText": "Operation",
"appSetting_dragCalendarByPageTile_titleText": "Drag calendar by page",
"appSetting_dragCalendarByPageTile_subtitleText": "If the switch is enabled, the app bar calendar on the home page will be dragged page by page. By default, the switch is disabled.",
"appSetting_changeRecordStatusOpTile_titleText": "Change Record Status",
"appSetting_changeRecordStatusOpTile_subtitleText": "Modify the click behavior to change the status of daily records on main page.",
"appSetting_openRecordStatusDialogOpTile_titleText": "Open Detailed Record",
"appSetting_openRecordStatusDialogOpTile_subtitleText": "Modify the click behavior to open the detailed popup for daily records on main page.",
"appSetting_firstDayOfWeek_titleText": "First day of week",
"appSetting_firstDayOfWeekDialog_titleText": "Show first day of week",
"appSetting_firstDayOfWeekDialog_defaultText": " (Default)",
Expand Down Expand Up @@ -655,5 +660,9 @@
"exportConfirmDialog_confirm_buttonText": "export",

"snackbar_undoText": "UNDO",
"snackbar_dissmessText": "DISMISS"
"snackbar_dissmessText": "DISMISS",

"userAction_tap": "Tap",
"userAction_doubleTap": "Double",
"userAction_longTap": "Long"
}
11 changes: 9 additions & 2 deletions assets/l10n/fa.arb
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,11 @@
"habitDetail_skipReason_saveText": "ذخیره",
"appSetting_appbar_titleText": "تنظیمات",
"appSetting_displaySubgroupText": "نمایش",
"appSetting_operationSubgroupText": "عملیات",
"appSetting_dragCalendarByPageTile_titleText": "جابجایی تقویم صفحه‌ای",
"appSetting_dragCalendarByPageTile_subtitleText": "در صورت فعال بودن این گزینه، تقویم نوار برنامه در صفحه اصلی صفحه به صفحه جابجا می‌شود. پیش‌فرض این گزینه غیرفعال است.",
"appSetting_changeRecordStatusOpTile_titleText": "تغییر وضعیت رکورد",
"appSetting_openRecordStatusDialogOpTile_titleText": "باز کردن رکورد تفصیلی",
"appSetting_firstDayOfWeek_titleText": "اولین روز هفته",
"appSetting_firstDayOfWeekDialog_titleText": "نمایش اولین روز هفته",
"appSetting_firstDayOfWeekDialog_defaultText": " (پیش‌فرض)",
Expand Down Expand Up @@ -568,5 +571,9 @@
"exportConfirmDialog_cancel_buttonText": "لغو",
"exportConfirmDialog_confirm_buttonText": "خروجی گرفتن",
"snackbar_undoText": "بازگشت",
"snackbar_dissmessText": "رد کردن"
}
"snackbar_dissmessText": "رد کردن",

"userAction_tap": "ضربه",
"userAction_doubleTap": "دوتایی",
"userAction_longTap": "طولانی"
}
11 changes: 10 additions & 1 deletion assets/l10n/zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,13 @@
"appSetting_appbar_titleText": "设置",

"appSetting_displaySubgroupText": "显示",
"appSetting_operationSubgroupText": "操作",
"appSetting_dragCalendarByPageTile_titleText": "按页拖动日历",
"appSetting_dragCalendarByPageTile_subtitleText": "如果启用开关,则主页上的应用栏日历将逐页拖动。默认情况下,该开关处于禁用状态。",
"appSetting_changeRecordStatusOpTile_titleText": "修改记录状态",
"appSetting_changeRecordStatusOpTile_subtitleText": "修改主页面上每日记录的状态的点击行为。",
"appSetting_openRecordStatusDialogOpTile_titleText": "打开详细记录",
"appSetting_openRecordStatusDialogOpTile_subtitleText": "修改主页面上打开每日记录详情弹窗的点击行为。",
"appSetting_firstDayOfWeek_titleText": "一周的第一天",
"appSetting_firstDayOfWeekDialog_titleText": "选择",
"appSetting_firstDayOfWeekDialog_defaultText": "(默认值)",
Expand Down Expand Up @@ -345,5 +350,9 @@
"exportConfirmDialog_confirm_buttonText": "导出",

"snackbar_undoText": "撤回",
"snackbar_dissmessText": "忽略"
"snackbar_dissmessText": "忽略",

"userAction_tap": "单击",
"userAction_doubleTap": "双击",
"userAction_longTap": "长按"
}
39 changes: 39 additions & 0 deletions lib/annotation/habit_display_op_config.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2023 Fries_I23
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'package:json_annotation/json_annotation.dart';

import '../common/enums.dart';
import '../model/habit_display.dart';

class HabitDisplayOpConfigConverter
implements JsonConverter<HabitDisplayOpConfig, List<int>> {
const HabitDisplayOpConfigConverter();

@override
HabitDisplayOpConfig fromJson(List<int> json) {
return HabitDisplayOpConfig(
changeRecordStatus: UserAction.getFromDBCode(json[0])!,
openRecordStatusDialog: UserAction.getFromDBCode(json[1])!,
);
}

@override
List<int> toJson(HabitDisplayOpConfig object) {
return [
object.changeRecordStatus.dbCode,
object.openRecordStatusDialog.dbCode,
];
}
}
1 change: 1 addition & 0 deletions lib/common/consts.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Fries_I23

Check warning on line 1 in lib/common/consts.dart

View workflow job for this annotation

GitHub Actions / analyzing / Analyze

Invalid format. For more details, see https://dart.dev/guides/language/effective-dart/style#formatting
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,6 +40,7 @@
const int appCalendarBarMaxOccupyPrt = 70;
const int appCalendarBarMinOccupyPrt = 20;
const int appCalendarBarDefualtOccupyPrt = 50;
const int kHabitLargeScreenAdaptWidth = 600;
//#endregion

//#region app-setting
Expand Down
22 changes: 22 additions & 0 deletions lib/common/enums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,25 @@ enum DonateWay {
return _name2EnumMap[name];
}
}

enum UserAction implements EnumWithDBCodeABC {
nothing(code: 0),
tap(code: 1),
doubleTap(code: 2),
longTap(code: 3);

final int _code;

const UserAction({required int code}) : _code = code;

@override
int get dbCode => _code;

static UserAction? getFromDBCode(int dbCode,
{UserAction? withDefault = UserAction.nothing}) {
for (var value in UserAction.values) {
if (value.dbCode == dbCode) return value;
}
return withDefault;
}
}
45 changes: 24 additions & 21 deletions lib/component/widgets/habit_daily_status_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ import '../../model/habit_daily_record_form.dart';
import '../../model/habit_form.dart';
import '../../theme/color.dart';

const kDefaultHabitDailyStatusContainerIconSize = 28.0;

class HabitDailyStatusContainer extends StatelessWidget {
final double? width;
final double? height;
final double? iconSize;
final EdgeInsetsGeometry? padding;
final HabitRecordDate date;
final HabitColorType colorType;
Expand All @@ -42,6 +45,7 @@ class HabitDailyStatusContainer extends StatelessWidget {
{super.key,
this.width,
this.height,
this.iconSize,
this.padding,
required this.date,
this.colorType = HabitColorType.cc1,
Expand All @@ -53,6 +57,8 @@ class HabitDailyStatusContainer extends StatelessWidget {
this.enabled = true,
this.isAutoComplated = false});

double getIconSize() => iconSize ?? kDefaultHabitDailyStatusContainerIconSize;

@override
Widget build(BuildContext context) {
ThemeData themeData = Theme.of(context);
Expand Down Expand Up @@ -165,30 +171,27 @@ class HabitDailyStatusContainer extends StatelessWidget {
}
}

return Container(
return Ink(
padding: padding ?? const EdgeInsets.all(8.0),
height: height,
width: width,
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
InkWell(
onLongPress: enabled && onLongPressed != null
? () => onLongPressed!(date, habitDailyStatus)
: null,
onDoubleTap: enabled && onDoublePressed != null
? () => onDoublePressed!(date, habitDailyStatus)
: null,
child: IconButton(
onPressed: enabled && onPressed != null
? () => onPressed!(date, habitDailyStatus)
: null,
icon: getButtonContent(),
),
),
],
child: InkWell(
onTap: enabled && onPressed != null
? () => onPressed!(date, habitDailyStatus)
: null,
onLongPress: enabled && onLongPressed != null
? () => onLongPressed!(date, habitDailyStatus)
: null,
onDoubleTap: enabled && onDoublePressed != null
? () => onDoublePressed!(date, habitDailyStatus)
: null,
customBorder: const CircleBorder(),
excludeFromSemantics: true,
child: IconButton(
iconSize: getIconSize(),
icon: getButtonContent(),
onPressed: null,
),
),
);
}
Expand Down
18 changes: 18 additions & 0 deletions lib/db/profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ abstract class ProfileInterface {

bool getCompactUISwticher();
Future<bool> setCompactUISwitcher(bool newStatus);

HabitDisplayOpConfig? getDisplayOpConfig();
Future<bool> setDisplayOpConfig(HabitDisplayOpConfig opConfig);
}

enum ProfileKey {
Expand All @@ -80,6 +83,7 @@ enum ProfileKey {
customDateYmdHmsConfig,
displayCalendarBarOccupyPrt,
compactUISwitcher,
displayOpConfig,
// cache
inputFillCache,
}
Expand Down Expand Up @@ -262,4 +266,18 @@ class Profile
return _pref.setString(
ProfileKey.inputFillCache.name, jsonEncode(newCache));
}

@override
HabitDisplayOpConfig getDisplayOpConfig() {
final raw = _pref.getString(ProfileKey.displayOpConfig.name);
return raw != null
? HabitDisplayOpConfig.fromJson(jsonDecode(raw))
: const HabitDisplayOpConfig.withDefault();
}

@override
Future<bool> setDisplayOpConfig(HabitDisplayOpConfig opConfig) {
return _pref.setString(
ProfileKey.displayOpConfig.name, jsonEncode(opConfig.toJson()));
}
}
48 changes: 48 additions & 0 deletions lib/l10n/localizations.g.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'dart:async';

Check warning on line 1 in lib/l10n/localizations.g.dart

View workflow job for this annotation

GitHub Actions / analyzing / Analyze

Invalid format. For more details, see https://dart.dev/guides/language/effective-dart/style#formatting

import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
Expand Down Expand Up @@ -1135,6 +1135,12 @@
/// **'Display'**
String get appSetting_displaySubgroupText;

/// No description provided for @appSetting_operationSubgroupText.
///
/// In en, this message translates to:
/// **'Operation'**
String get appSetting_operationSubgroupText;

/// No description provided for @appSetting_dragCalendarByPageTile_titleText.
///
/// In en, this message translates to:
Expand All @@ -1147,6 +1153,30 @@
/// **'If the switch is enabled, the app bar calendar on the home page will be dragged page by page. By default, the switch is disabled.'**
String get appSetting_dragCalendarByPageTile_subtitleText;

/// No description provided for @appSetting_changeRecordStatusOpTile_titleText.
///
/// In en, this message translates to:
/// **'Change Record Status'**
String get appSetting_changeRecordStatusOpTile_titleText;

/// No description provided for @appSetting_changeRecordStatusOpTile_subtitleText.
///
/// In en, this message translates to:
/// **'Modify the click behavior to change the status of daily records on main page.'**
String get appSetting_changeRecordStatusOpTile_subtitleText;

/// No description provided for @appSetting_openRecordStatusDialogOpTile_titleText.
///
/// In en, this message translates to:
/// **'Open Detailed Record'**
String get appSetting_openRecordStatusDialogOpTile_titleText;

/// No description provided for @appSetting_openRecordStatusDialogOpTile_subtitleText.
///
/// In en, this message translates to:
/// **'Modify the click behavior to open the detailed popup for daily records on main page.'**
String get appSetting_openRecordStatusDialogOpTile_subtitleText;

/// No description provided for @appSetting_firstDayOfWeek_titleText.
///
/// In en, this message translates to:
Expand Down Expand Up @@ -1806,6 +1836,24 @@
/// In en, this message translates to:
/// **'DISMISS'**
String get snackbar_dissmessText;

/// No description provided for @userAction_tap.
///
/// In en, this message translates to:
/// **'Tap'**
String get userAction_tap;

/// No description provided for @userAction_doubleTap.
///
/// In en, this message translates to:
/// **'Double'**
String get userAction_doubleTap;

/// No description provided for @userAction_longTap.
///
/// In en, this message translates to:
/// **'Long'**
String get userAction_longTap;
}

class _L10nDelegate extends LocalizationsDelegate<L10n> {
Expand Down
Loading
Loading