Skip to content

Commit

Permalink
Fix error on timezone screen
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanSarwar45 committed Sep 15, 2024
1 parent 809b9ab commit 88e3cc0
Show file tree
Hide file tree
Showing 15 changed files with 261 additions and 67 deletions.
25 changes: 25 additions & 0 deletions lib/alarm/data/alarm_app_settings_schema.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:clock_app/alarm/data/alarm_settings_schema.dart';
import 'package:clock_app/alarm/types/notification_action.dart';
import 'package:clock_app/common/types/list_filter.dart';
import 'package:clock_app/icons/flux_icons.dart';
import 'package:clock_app/notifications/widgets/notification_actions/area_notification_action.dart';
import 'package:clock_app/notifications/widgets/notification_actions/buttons_notification_action.dart';
Expand Down Expand Up @@ -73,6 +74,30 @@ SettingGroup alarmAppSettingsSchema = SettingGroup(
]),
SettingGroup("Filters",
(context) => AppLocalizations.of(context)!.filtersSettingGroup, [
// CustomizableListSetting<ListFilter>(
// "Tasks",
// (context) => AppLocalizations.of(context)!.tasksSetting,
// [],
// // kDebugMode
// // ? [AlarmTask(AlarmTaskType.math), AlarmTask(AlarmTaskType.sequence)]
// // : [],
// alarmTaskSchemasMap.keys.map((key) => AlarmTask(key)).toList(),
// addCardBuilder: (item) => AlarmTaskCard(task: item, isAddCard: true),
// cardBuilder: (item, [onDelete, onDuplicate]) => AlarmTaskCard(
// task: item,
// isAddCard: false,
// onPressDelete: onDelete,
// onPressDuplicate: onDuplicate,
// ),
// valueDisplayBuilder: (context, setting) {
// return Text("${setting.value.length} tasks");
// },
// itemPreviewBuilder: (item) => TryAlarmTaskButton(alarmTask: item),
// // onChange: (context, value)async{
// // await appSettings.save();
// // }
// ),

SwitchSetting("Show Filters",
(context) => AppLocalizations.of(context)!.showFiltersSetting, true),
SwitchSetting("Show Sort",
Expand Down
33 changes: 7 additions & 26 deletions lib/alarm/data/alarm_settings_schema.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:clock_app/alarm/types/schedules/weekly_alarm_schedule.dart';
import 'package:clock_app/alarm/widgets/alarm_task_card.dart';
import 'package:clock_app/alarm/widgets/try_alarm_task_button.dart';
import 'package:clock_app/audio/audio_channels.dart';
import 'package:clock_app/audio/screens/ringtones_screen.dart';
import 'package:clock_app/audio/types/ringtone_player.dart';
import 'package:clock_app/common/data/weekdays.dart';
import 'package:clock_app/common/logic/tags.dart';
Expand All @@ -19,13 +20,11 @@ import 'package:clock_app/common/types/tag.dart';
import 'package:clock_app/common/types/weekday.dart';
import 'package:clock_app/common/utils/ringtones.dart';
import 'package:clock_app/settings/data/settings_schema.dart';
import 'package:clock_app/settings/screens/ringtones_screen.dart';
import 'package:clock_app/settings/screens/tags_screen.dart';
import 'package:clock_app/settings/types/setting.dart';
import 'package:clock_app/settings/types/setting_enable_condition.dart';
import 'package:clock_app/settings/types/setting_group.dart';
import 'package:clock_app/timer/types/time_duration.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

Expand Down Expand Up @@ -78,20 +77,6 @@ SettingGroup alarmSettingsSchema = SettingGroup(
),
],
),
// DynamicToggleSetting(
// "Week Days",
// (context) => AppLocalizations.of(context)!.alarmWeekdaysSetting,
// () {
// return weekdays
// .map((weekday) => SelectSettingOption(
// (context) => weekday.getAbbreviation(context), weekday))
// .toList();
// },
// enableConditions: [
// ValueCondition(["Type"], (value) => value == WeeklyAlarmSchedule)
// ],
// ),

ToggleSetting(
"Week Days",
(context) => AppLocalizations.of(context)!.alarmWeekdaysSetting,
Expand Down Expand Up @@ -195,14 +180,13 @@ SettingGroup alarmSettingsSchema = SettingGroup(
],
// shouldCloseOnSelect: false,
),
SwitchSetting(
SwitchSetting(
"start_melody_at_random_pos",
(context) => AppLocalizations.of(context)!.startMelodyAtRandomPos,
false,
getDescription: (context) => AppLocalizations.of(context)!.startMelodyAtRandomPosDescription,

getDescription: (context) => AppLocalizations.of(context)!
.startMelodyAtRandomPosDescription,
),

SliderSetting(
"Volume",
(context) => AppLocalizations.of(context)!.volumeSetting,
Expand Down Expand Up @@ -309,13 +293,13 @@ SettingGroup alarmSettingsSchema = SettingGroup(
"Length",
],
),
ListSetting<AlarmTask>(
CustomizableListSetting<AlarmTask>(
"Tasks",
(context) => AppLocalizations.of(context)!.tasksSetting,
[],
// kDebugMode
// ? [AlarmTask(AlarmTaskType.math), AlarmTask(AlarmTaskType.sequence)]
// : [],
// ? [AlarmTask(AlarmTaskType.math), AlarmTask(AlarmTaskType.sequence)]
// : [],
alarmTaskSchemasMap.keys.map((key) => AlarmTask(key)).toList(),
addCardBuilder: (item) => AlarmTaskCard(task: item, isAddCard: true),
cardBuilder: (item, [onDelete, onDuplicate]) => AlarmTaskCard(
Expand All @@ -328,9 +312,6 @@ SettingGroup alarmSettingsSchema = SettingGroup(
return Text("${setting.value.length} tasks");
},
itemPreviewBuilder: (item) => TryAlarmTaskButton(alarmTask: item),
// onChange: (context, value)async{
// await appSettings.save();
// }
),
DynamicMultiSelectSetting<Tag>(
"Tags",
Expand Down
3 changes: 1 addition & 2 deletions lib/alarm/widgets/try_alarm_task_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import 'package:clock_app/common/widgets/card_container.dart';
import 'package:flutter/material.dart';

class TryAlarmTaskButton extends StatelessWidget {
const TryAlarmTaskButton({Key? key, required this.alarmTask})
: super(key: key);
const TryAlarmTaskButton({super.key, required this.alarmTask});

final AlarmTask alarmTask;

Expand Down
26 changes: 14 additions & 12 deletions lib/clock/screens/search_city_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,21 @@ class _SearchCityScreenState extends State<SearchCityScreen> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppTopBar(
titleWidget: TextField(
autofocus: true,
controller: _filterController,
decoration: InputDecoration(
border: InputBorder.none,
focusedBorder:
const OutlineInputBorder(borderSide: BorderSide.none),
fillColor: Colors.transparent,
hintText: AppLocalizations.of(context)!.searchCityPlaceholder,
hintStyle: Theme.of(context).textTheme.bodyLarge,
titleWidget: Expanded(
child: TextField(
autofocus: true,
controller: _filterController,
decoration: InputDecoration(
border: InputBorder.none,
focusedBorder:
const OutlineInputBorder(borderSide: BorderSide.none),
fillColor: Colors.transparent,
hintText: AppLocalizations.of(context)!.searchCityPlaceholder,
hintStyle: Theme.of(context).textTheme.bodyLarge,
),
textAlignVertical: TextAlignVertical.center,
style: Theme.of(context).textTheme.bodyLarge,
),
textAlignVertical: TextAlignVertical.center,
style: Theme.of(context).textTheme.bodyLarge,
),
),
body: Padding(
Expand Down
12 changes: 6 additions & 6 deletions lib/common/types/list_filter.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import 'package:clock_app/common/types/json.dart';
import 'package:clock_app/common/types/list_item.dart';
import 'package:clock_app/common/utils/id.dart';
import 'package:clock_app/developer/logic/logger.dart';
import 'package:clock_app/settings/types/setting_group.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class ListSortOption<Item extends ListItem> {
final String Function(BuildContext) getLocalizedName;
// final String abbreviation;
final int Function(Item, Item) sortFunction;

String Function(BuildContext) get displayName => getLocalizedName;

const ListSortOption(
this.getLocalizedName, this.sortFunction);
const ListSortOption(this.getLocalizedName, this.sortFunction);
}

abstract class ListFilterItem<Item extends ListItem> {
bool isEnabled = true;

bool Function(Item) get filterFunction;
String Function(BuildContext) get displayName;
bool get isActive;
Expand Down Expand Up @@ -45,7 +45,6 @@ class ListFilter<Item extends ListItem> extends ListFilterItem<Item> {

@override
bool Function(Item) get filterFunction {
// print("Filtering $name $isSelected");
return isSelected ? _filterFunction : (Item item) => true;
}

Expand All @@ -64,6 +63,7 @@ class ListFilter<Item extends ListItem> extends ListFilterItem<Item> {
class ListFilterSearch<Item extends ListItem> extends ListFilterItem<Item> {
final String Function(BuildContext) getLocalizedName;
String searchText = '';

@override
bool Function(Item) get filterFunction {
// if (searchText.isEmpty) {
Expand Down
2 changes: 1 addition & 1 deletion lib/settings/data/general_settings_schema.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:io';
import 'package:app_settings/app_settings.dart';
import 'package:auto_start_flutter/auto_start_flutter.dart';
import 'package:clock_app/app.dart';
import 'package:clock_app/audio/screens/ringtones_screen.dart';
import 'package:clock_app/clock/types/time.dart';
import 'package:clock_app/common/data/weekdays.dart';
import 'package:clock_app/common/types/weekday.dart';
Expand All @@ -12,7 +13,6 @@ import 'package:clock_app/common/utils/time_format.dart';
import 'package:clock_app/icons/flux_icons.dart';
import 'package:clock_app/l10n/language_local.dart';
import 'package:clock_app/notifications/logic/notifications.dart';
import 'package:clock_app/settings/screens/ringtones_screen.dart';
import 'package:clock_app/settings/screens/tags_screen.dart';
import 'package:clock_app/settings/types/setting.dart';
import 'package:clock_app/settings/types/setting_action.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/settings/logic/get_setting_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Widget? getSettingItemWidget(
setting: item,
showAsCard: showAsCard,
);
} else if (item is ListSetting) {
} else if (item is CustomizableListSetting) {
return ListSettingCard(
setting: item,
showAsCard: showAsCard,
Expand Down
67 changes: 67 additions & 0 deletions lib/settings/screens/list_filter_settings_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import 'package:clock_app/common/types/tag.dart';
import 'package:clock_app/common/widgets/fab.dart';
import 'package:clock_app/common/widgets/fields/input_bottom_sheet.dart';
import 'package:clock_app/common/widgets/list/persistent_list_view.dart';
import 'package:clock_app/navigation/widgets/app_top_bar.dart';
import 'package:clock_app/settings/widgets/tag_card.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class ListFilterSettingsScreen extends StatefulWidget {
const ListFilterSettingsScreen({
super.key,
});

@override
State<ListFilterSettingsScreen> createState() =>
_ListFilterSettingsScreenState();
}

class _ListFilterSettingsScreenState extends State<ListFilterSettingsScreen> {
final _listController = PersistentListController<Tag>();

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppTopBar(title: AppLocalizations.of(context)!.tagsSetting),
body: Stack(
children: [
Column(
children: [
Expanded(
child: PersistentListView<Tag>(
saveTag: 'tags',
listController: _listController,
itemBuilder: (tag) => TagCard(
key: ValueKey(tag),
tag: tag,
onPressDelete: () => _listController.deleteItem(tag),
onPressDuplicate: () => _listController.duplicateItem(tag),
),
onTapItem: (tag, index) async {
Tag? newTag = await showTagEditor(tag);
if (newTag == null) return;
tag.copyFrom(newTag);
_listController.changeItems((tags) {});
},
// onDeleteItem: _handleDeleteTimer,
placeholderText: "No tags created",
reloadOnPop: true,
isSelectable: true,
),
),
],
),
FAB(
bottomPadding: 8,
onPressed: () async {
Tag? tag = await showTagEditor();
if (tag == null) return;
_listController.addItem(tag);
},
)
],
),
);
}
}
1 change: 0 additions & 1 deletion lib/settings/screens/tags_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:clock_app/common/widgets/fab.dart';
import 'package:clock_app/common/widgets/fields/input_bottom_sheet.dart';
import 'package:clock_app/common/widgets/list/persistent_list_view.dart';
import 'package:clock_app/navigation/widgets/app_top_bar.dart';
import 'package:clock_app/navigation/widgets/search_top_bar.dart';
import 'package:clock_app/settings/widgets/tag_card.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Expand Down
Loading

0 comments on commit 88e3cc0

Please sign in to comment.