Skip to content

Commit

Permalink
feat: declutter entry header, hide most icons by default
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasn committed Jan 1, 2024
1 parent 2a2a476 commit 73544ce
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 40 deletions.
104 changes: 65 additions & 39 deletions lib/widgets/journal/entry_details/entry_detail_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:lotti/widgets/journal/entry_details/share_button_widget.dart';
import 'package:lotti/widgets/journal/tags/tag_add.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';

class EntryDetailHeader extends StatelessWidget {
class EntryDetailHeader extends StatefulWidget {
const EntryDetailHeader({
this.inLinkedEntries = false,
super.key,
Expand All @@ -24,6 +24,13 @@ class EntryDetailHeader extends StatelessWidget {
final bool inLinkedEntries;
final Future<void> Function()? unlinkFn;

@override
State<EntryDetailHeader> createState() => _EntryDetailHeaderState();
}

class _EntryDetailHeaderState extends State<EntryDetailHeader> {
bool showAllIcons = false;

@override
Widget build(BuildContext context) {
final localizations = AppLocalizations.of(context)!;
Expand Down Expand Up @@ -56,14 +63,6 @@ class EntryDetailHeader extends StatelessWidget {
activeIcon: Icons.star_rounded,
activeColor: starredGold,
),
SwitchIconWidget(
tooltip: localizations.journalPrivateTooltip,
onPressed: cubit.togglePrivate,
value: item.meta.private ?? false,
icon: Icons.shield_outlined,
activeIcon: Icons.shield,
activeColor: Theme.of(context).colorScheme.error,
),
SwitchIconWidget(
tooltip: localizations.journalFlaggedTooltip,
onPressed: cubit.toggleFlagged,
Expand All @@ -72,45 +71,72 @@ class EntryDetailHeader extends StatelessWidget {
activeIcon: Icons.flag,
activeColor: Theme.of(context).colorScheme.error,
),
if (state.entry?.geolocation != null)
if (!showAllIcons)
SizedBox(
width: 40,
child: IconButton(
icon: const Icon(Icons.more_horiz),
tooltip: localizations.journalLinkFromHint,
onPressed: () => setState(() => showAllIcons = true),
),
)
else ...[
SwitchIconWidget(
tooltip: state.showMap
? localizations.journalHideMapHint
: localizations.journalShowMapHint,
onPressed: cubit.toggleMapVisible,
value: cubit.showMap,
icon: Icons.map_outlined,
activeIcon: Icons.map,
activeColor: Theme.of(context).primaryColor,
tooltip: localizations.journalPrivateTooltip,
onPressed: cubit.togglePrivate,
value: item.meta.private ?? false,
icon: Icons.shield_outlined,
activeIcon: Icons.shield,
activeColor: Theme.of(context).colorScheme.error,
),
DeleteIconWidget(beamBack: !inLinkedEntries),
const ShareButtonWidget(),
TagAddIconWidget(),
SizedBox(
width: 40,
child: IconButton(
icon: const Icon(Icons.add_link),
tooltip: localizations.journalLinkFromHint,
onPressed: () => linkService.linkFrom(id),
if (state.entry?.geolocation != null)
SwitchIconWidget(
tooltip: state.showMap
? localizations.journalHideMapHint
: localizations.journalShowMapHint,
onPressed: cubit.toggleMapVisible,
value: cubit.showMap,
icon: Icons.map_outlined,
activeIcon: Icons.map,
activeColor: Theme.of(context).primaryColor,
),
DeleteIconWidget(beamBack: !widget.inLinkedEntries),
const ShareButtonWidget(),
TagAddIconWidget(),
SizedBox(
width: 40,
child: IconButton(
icon: const Icon(Icons.add_link),
tooltip: localizations.journalLinkFromHint,
onPressed: () => linkService.linkFrom(id),
),
),
),
SizedBox(
width: 40,
child: IconButton(
icon: Icon(MdiIcons.target),
tooltip: localizations.journalLinkToHint,
onPressed: () => linkService.linkTo(id),
SizedBox(
width: 40,
child: IconButton(
icon: Icon(MdiIcons.target),
tooltip: localizations.journalLinkToHint,
onPressed: () => linkService.linkTo(id),
),
),
),
if (unlinkFn != null)
if (widget.unlinkFn != null)
SizedBox(
width: 40,
child: IconButton(
icon: Icon(MdiIcons.linkOff),
tooltip: localizations.journalUnlinkHint,
onPressed: widget.unlinkFn,
),
),
SizedBox(
width: 40,
child: IconButton(
icon: Icon(MdiIcons.closeCircleOutline),
tooltip: localizations.journalUnlinkHint,
onPressed: unlinkFn,
icon: const Icon(Icons.more_outlined),
tooltip: localizations.journalLinkFromHint,
onPressed: () => setState(() => showAllIcons = false),
),
),
],
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: lotti
description: Achieve your goals and keep your data private with Lotti.
publish_to: 'none'
version: 0.9.397+2311
version: 0.9.397+2312

msix_config:
display_name: LottiApp
Expand Down

0 comments on commit 73544ce

Please sign in to comment.