Skip to content
Open
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
8 changes: 3 additions & 5 deletions lib/alarm/screens/alarm_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import 'package:clock_app/settings/types/setting.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';


class AlarmScreen extends StatefulWidget {
const AlarmScreen({super.key, this.actionController});

Expand Down Expand Up @@ -130,10 +129,8 @@ class _AlarmScreenState extends State<AlarmScreen> {
DateTime? nextScheduleDateTime = alarm.currentScheduleDateTime;
if (nextScheduleDateTime == null) return;
ScaffoldMessenger.of(context).showSnackBar(getThemedSnackBar(
context,
getNewAlarmText(context, alarm),
fab: true,
navBar: true));
context, getNewAlarmText(context, alarm),
fab: true, navBar: true));
});
}

Expand Down Expand Up @@ -314,6 +311,7 @@ class _AlarmScreenState extends State<AlarmScreen> {
listFilters: _getListFilterItems(),
customActions: _getCustomActions(),
sortOptions: _showSort.value ? alarmSortOptions : [],
bottomInset: FAB.bottomInset(context),
),
FAB(
onPressed: handleAddAlarmActon,
Expand Down
1 change: 1 addition & 0 deletions lib/clock/screens/clock_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class _ClockScreenState extends State<ClockScreen> {
placeholderText: "No cities added",
isDuplicateEnabled: false,
isSelectable: true,
bottomInset: FAB.bottomInset(context),
),
),
]),
Expand Down
32 changes: 27 additions & 5 deletions lib/common/widgets/fab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import 'package:flutter/material.dart';

enum FabPosition { bottomLeft, bottomRight }

const double _kIconSize = 24.0;
const double _kMaterialStyleBottomPadding = 20.0;
const double _kPadding = 16.0;

class FAB extends StatefulWidget {
const FAB({
super.key,
Expand All @@ -27,6 +31,24 @@ class FAB extends StatefulWidget {

@override
State<FAB> createState() => _FABState();

static double bottomInset(
BuildContext context, {
int size = 1,
double bottomPadding = 0,
}) {
ThemeData theme = Theme.of(context);
ThemeSettingExtension themeSettings =
theme.extension<ThemeSettingExtension>()!;

const paddingHeight = 2 * _kPadding;
final iconHeight = _kIconSize * size;
final totalHeight = bottomPadding + paddingHeight + iconHeight;

return themeSettings.useMaterialStyle
? totalHeight + _kMaterialStyleBottomPadding
: totalHeight;
}
}

class _FABState extends State<FAB> {
Expand Down Expand Up @@ -65,27 +87,27 @@ class _FABState extends State<FAB> {
: widget.position;

double bottomPadding = themeSettings.useMaterialStyle
? widget.bottomPadding + 20
? widget.bottomPadding + _kMaterialStyleBottomPadding
: widget.bottomPadding;

return Positioned(
bottom: bottomPadding,
right: position == FabPosition.bottomRight
? 16 + (widget.index * 24 * widget.size) + widget.index * 36
? 16 + (widget.index * _kIconSize * widget.size) + widget.index * 36
: null,
left: position == FabPosition.bottomLeft
? 16 + (widget.index * 24 * widget.size) + widget.index * 36
? 16 + (widget.index * _kIconSize * widget.size) + widget.index * 36
: null,
child: CardContainer(
elevationMultiplier: 2,
color: colorScheme.primary,
onTap: widget.onPressed,
child: Padding(
padding: const EdgeInsets.all(16.0),
padding: const EdgeInsets.all(_kPadding),
child: Icon(
widget.icon,
color: colorScheme.onPrimary,
size: 24 * widget.size,
size: _kIconSize * widget.size,
),
),
),
Expand Down
10 changes: 8 additions & 2 deletions lib/common/widgets/list/custom_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class CustomListView<Item extends ListItem> extends StatefulWidget {
this.initialSortIndex = 0,
this.onChangeSortIndex,
this.header,
this.bottomInset = 0,
});

final List<Item> items;
Expand All @@ -60,6 +61,7 @@ class CustomListView<Item extends ListItem> extends StatefulWidget {
final Function(int index)? onChangeSortIndex;
final Widget? header;
final bool isSelectable;
final double bottomInset;

@override
State<CustomListView> createState() => _CustomListViewState<Item>();
Expand Down Expand Up @@ -387,8 +389,12 @@ class _CustomListViewState<Item extends ListItem>
proxyDecorator: (widget, index, animation) =>
reorderableListDecorator(context, widget),
items: currentList,
padding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
padding: EdgeInsets.only(
left: 16,
top: 8,
right: 16,
bottom: widget.bottomInset + 8,
),
isSameItem: (a, b) => a.id == b.id,
scrollDirection: Axis.vertical,
itemBuilder: _getItemBuilder(),
Expand Down
16 changes: 9 additions & 7 deletions lib/common/widgets/list/persistent_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:clock_app/common/types/list_controller.dart';
import 'package:clock_app/common/types/list_filter.dart';
import 'package:clock_app/common/types/list_item.dart';
import 'package:clock_app/common/utils/list_storage.dart';
import 'package:clock_app/common/widgets/fab.dart';
import 'package:clock_app/common/widgets/list/custom_list_view.dart';
import 'package:clock_app/developer/logic/logger.dart';
import 'package:clock_app/settings/types/listener_manager.dart';
Expand Down Expand Up @@ -78,7 +79,8 @@ class PersistentListView<Item extends ListItem> extends StatefulWidget {
this.customActions = const [],
this.sortOptions = const [],
this.header,
this.onSaveItems ,
this.onSaveItems,
this.bottomInset = 0,
// this.initialSortIndex = 0,
});

Expand All @@ -96,12 +98,13 @@ class PersistentListView<Item extends ListItem> extends StatefulWidget {
final bool reloadOnPop;
final bool isSelectable;
final bool shouldInsertOnTop;
final Widget? header;
final Widget? header;
// final int initialSortIndex;
final List<ListFilterItem<Item>> listFilters;
final List<ListFilterCustomAction<Item>> customActions;
final List<ListSortOption<Item>> sortOptions;
final Function(List<Item> items)? onSaveItems;
final double bottomInset;

@override
State<PersistentListView> createState() => _PersistentListViewState<Item>();
Expand Down Expand Up @@ -130,16 +133,15 @@ class _PersistentListViewState<Item extends ListItem>
_initialSortIndex =
int.parse(loadTextFileSync("${widget.saveTag}-sort-index"));
}
}
else {
} else {
_initialSortIndex = 0;
}
}

@override
void dispose() {
ListenerManager.removeOnChangeListener(widget.saveTag, _loadItems);

super.dispose();
}

Expand All @@ -161,12 +163,11 @@ class _PersistentListViewState<Item extends ListItem>
}
}

void _saveItems () async {
void _saveItems() async {
if (widget.saveTag.isNotEmpty) {
await saveList<Item>(widget.saveTag, _items);
}
widget.onSaveItems?.call(_items);

}

void _handleChangeSort(int index) {
Expand Down Expand Up @@ -197,6 +198,7 @@ class _PersistentListViewState<Item extends ListItem>
initialSortIndex: _initialSortIndex,
onChangeSortIndex: _handleChangeSort,
header: widget.header,
bottomInset: widget.bottomInset,
);
}
}
1 change: 1 addition & 0 deletions lib/stopwatch/screens/stopwatch_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class _StopwatchScreenState extends State<StopwatchScreen> {
isDuplicateEnabled: false,
isReorderable: false,
onAddItem: (lap) => _stopwatch.updateFastestAndSlowestLap(),
bottomInset: FAB.bottomInset(context, size: 2),
),
),
],
Expand Down
2 changes: 1 addition & 1 deletion lib/timer/screens/timer_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
// }
// }


class TimerScreen extends StatefulWidget {
const TimerScreen({super.key, this.actionController});

Expand Down Expand Up @@ -410,6 +409,7 @@ class _TimerScreenState extends State<TimerScreen> {
listFilters: _showFilters.value ? timerListFilters : [],
sortOptions: _showSort.value ? timerSortOptions : [],
customActions: _getCustomActions(),
bottomInset: FAB.bottomInset(context),
),
),
],
Expand Down