Skip to content
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
12 changes: 12 additions & 0 deletions lib/core/iconography.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ class KapyIcons {
0xE017,
HugeIcons.strokeRoundedMinimizeScreen,
);
static const cloudRounded = KapyIconData(
0xE0D3,
HugeIcons.strokeRoundedCloud,
);
static const cloudOffRounded = KapyIconData(
0xE018,
HugeIcons.strokeRoundedCloudOff,
Expand Down Expand Up @@ -347,6 +351,10 @@ class KapyIcons {
0xE048,
HugeIcons.strokeRoundedUserGroup,
);
static const personAddRounded = KapyIconData(
0xE0D4,
HugeIcons.strokeRoundedUserAdd01,
);
static const groupOutlined = KapyIconData(
0xE092,
HugeIcons.strokeRoundedUserMultiple,
Expand All @@ -355,6 +363,10 @@ class KapyIcons {
0xE0D0,
HugeIcons.strokeRoundedFilterHorizontal,
);
static const layersRounded = KapyIconData(
0xE0D5,
HugeIcons.strokeRoundedLayers01,
);
static const listViewRounded = KapyIconData(
0xE0D1,
HugeIcons.strokeRoundedListView,
Expand Down
17 changes: 17 additions & 0 deletions lib/core/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ class CalcPalette extends ThemeExtension<CalcPalette> {
final Color cardTitle;
final Color accentText;

/// The page's edge, and the slash between a breadcrumb's steps or the dot
/// between a note's dates: fainter than any text that is meant to be read.
final Color pageBorder;
final Color textDivider;

/// How much of the desktop the window's chrome lets through: a multiplier on
/// the alpha of every [GlassSurface]. 1 is fully opaque.
///
Expand Down Expand Up @@ -237,6 +242,8 @@ class CalcPalette extends ThemeExtension<CalcPalette> {
required this.switchTrackOff,
required this.cardTitle,
required this.accentText,
required this.pageBorder,
required this.textDivider,
this.translucency = 1,
this.paperTranslucency = 1,
});
Expand Down Expand Up @@ -301,6 +308,8 @@ class CalcPalette extends ThemeExtension<CalcPalette> {
Color? switchTrackOff,
Color? cardTitle,
Color? accentText,
Color? pageBorder,
Color? textDivider,
double? translucency,
double? paperTranslucency,
}) => CalcPalette(
Expand Down Expand Up @@ -362,6 +371,8 @@ class CalcPalette extends ThemeExtension<CalcPalette> {
switchTrackOff: switchTrackOff ?? this.switchTrackOff,
cardTitle: cardTitle ?? this.cardTitle,
accentText: accentText ?? this.accentText,
pageBorder: pageBorder ?? this.pageBorder,
textDivider: textDivider ?? this.textDivider,
translucency: translucency ?? this.translucency,
paperTranslucency: paperTranslucency ?? this.paperTranslucency,
);
Expand Down Expand Up @@ -432,6 +443,8 @@ class CalcPalette extends ThemeExtension<CalcPalette> {
switchTrackOff: mix(switchTrackOff, other.switchTrackOff),
cardTitle: mix(cardTitle, other.cardTitle),
accentText: mix(accentText, other.accentText),
pageBorder: mix(pageBorder, other.pageBorder),
textDivider: mix(textDivider, other.textDivider),
translucency: translucency + (other.translucency - translucency) * t,
paperTranslucency:
paperTranslucency + (other.paperTranslucency - paperTranslucency) * t,
Expand Down Expand Up @@ -1015,6 +1028,8 @@ class KapyTheme {
switchTrackOff: Color(0xFF3A362F),
cardTitle: Color(0xFFD9D3C6),
accentText: Color(0xFF9DB384),
pageBorder: Color(0xFF2E2A25),
textDivider: Color(0xFF554F47),
);

/// A cool, clean paper palette rather than the previous warm stationery.
Expand Down Expand Up @@ -1079,6 +1094,8 @@ class KapyTheme {
switchTrackOff: Color(0xFFDAD8D2),
cardTitle: Color(0xFF2A2620),
accentText: Color(0xFF56703C),
pageBorder: Color(0xFFE3E1DC),
textDivider: Color(0xFFB9BBC0),
);

/// Transparency mode.
Expand Down
74 changes: 74 additions & 0 deletions lib/ui/context_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,77 @@ class _KapyContextMenuLayout extends SingleChildLayoutDelegate {
preferredBounds != oldDelegate.preferredBounds ||
mediaPadding != oldDelegate.mediaPadding;
}

/// One line of a note's actions menu, wherever it opens: a note's row in the
/// list, or the page's More button.
class KapyMenuAction {
const KapyMenuAction({
required this.value,
required this.label,
required this.icon,
this.hint,
this.destructive = false,
this.enabled = true,
});

final String value;
final String label;
final KapyIconData icon;
final String? hint;
final bool destructive;
final bool enabled;
}

/// A [KapyMenuAction] as drawn in a desktop menu or a touch sheet.
class KapyMenuActionRow extends StatelessWidget {
const KapyMenuActionRow(this.action, {super.key, required this.touch});

final KapyMenuAction action;
final bool touch;

@override
Widget build(BuildContext context) {
final palette = context.palette;
final foreground = !action.enabled
? palette.textTertiary
: action.destructive
? Theme.of(context).colorScheme.error
: palette.textPrimary;
return Row(
children: [
KapyIcon(
action.icon,
size: touch
? AppControlMetrics.iconAction
: AppControlMetrics.iconControl,
color: action.destructive || !action.enabled
? foreground
: palette.textSecondary,
),
SizedBox(width: touch ? 14 : 10),
Expanded(
child: Text(
action.label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: touch ? AppTypeScale.body : AppTypeScale.control,
color: foreground,
),
),
),
if (action.hint case final hint?) ...[
SizedBox(width: touch ? 18 : 10),
Text(
hint,
maxLines: 1,
style: TextStyle(
fontSize: AppTypeScale.control,
color: palette.textTertiary,
),
),
],
],
);
}
}
165 changes: 128 additions & 37 deletions lib/ui/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ import 'editor_panes.dart';
import 'billing/note_limit_dialog.dart';
import 'billing/pro_sheet.dart';
import 'empty_state.dart';
import 'context_menu.dart';
import 'hidden_notes_gate.dart';
import 'kapy_header_mascot.dart';
import 'mobile_page_swipe.dart';
import 'notes_list.dart';
import 'page_card.dart';
import 'page_toolbar.dart';
import 'sidebar.dart';
import 'settings_dialog.dart';
import 'sidebar_swipe.dart';
Expand Down Expand Up @@ -2557,6 +2560,9 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
final space = _space;
final listFits = _listFits;
final listShown = _listShown;
final pinned =
selected != null &&
widget.notes.pinnedNoteIds.contains(selected.id);
return Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expand Down Expand Up @@ -2698,32 +2704,41 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
pageInset,
pageInset,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
NoteToolbar(
mascotController: _kapyHeader,
sidebarVisible: listShown,
sidebarShortcut: _sidebarShortcut,
onToggleSidebar: _toggleList,
onCreate: _createNote,
onShare: _shareSelected,
members: _selectedMembers,
present: _selectedPresence,
currentUserId:
widget.account?.sharing?.userId ?? '',
noteShared: selected?.isShared ?? false,
alwaysOnTop: widget.prefs.alwaysOnTop,
onToggleAlwaysOnTop: _pinToggle,
alwaysOnTopShortcut: _pinShortcut,
onSplit: _specialMode || !_workspace.canSplit
? null
: _splitEditor,
splitTooltip: _splitTooltip,
updates: widget.updates,
),
Expanded(child: _buildWideWorkspace()),
],
child: PageCard(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
PageToolbar(
space: space.title,
section: pinned ? 'Pinned' : null,
listVisible: listFits && listShown,
onShowList: _toggleList,
showListShortcut: _sidebarShortcut,
onCreate: _createNote,
newNoteShortcut: widget.shortcuts
.bindingFor(ShortcutAction.newNote)
?.displayLabel,
noteOpen: selected != null,
syncStatus: widget.account?.sync?.status,
members: _selectedMembers,
present: _selectedPresence,
currentUserId:
widget.account?.sharing?.userId ?? '',
noteShared: selected?.isShared ?? false,
onShare: _shareSelected,
pinned: pinned,
onTogglePin:
selected == null || _specialMode
? null
: () => _togglePinnedNote(selected.id),
moreActions: _pageActions(selected),
onMore: (action) =>
_runPageAction(action, selected),
updates: widget.updates,
),
Expanded(child: _buildWideWorkspace()),
],
),
),
),
],
Expand All @@ -2739,18 +2754,91 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
);
}

/// The split button's words, which also say why it is grey when it is.
String get _splitTooltip {
if (!_specialMode) {
if (_workspace.paneCount >= EditorWorkspace.maxPanes) {
return 'Up to three notes side by side';
}
if (_selectedId == null) return 'Choose a note for this pane first';
}
/// What the page's More menu offers: the window's own actions, then the
/// open note's, in the order and on the terms of that note's menu in the
/// list.
List<KapyMenuAction> _pageActions(Note? note) {
final splitBlocker = _specialMode
? null
: _workspace.paneCount >= EditorWorkspace.maxPanes
? 'Up to three notes side by side'
: _selectedId == null
? 'Choose a note for this pane first'
: null;
final canSplit = !_specialMode && _workspace.canSplit;
final mayEdit = note != null && _canEditNote(note);
final removeShortcut = widget.shortcuts
.bindingFor(ShortcutAction.deleteNote)
?.displayLabel;
final alwaysOnTop = widget.prefs.alwaysOnTop;
return [
'Split view',
?widget.shortcuts.bindingFor(ShortcutAction.splitEditor)?.displayLabel,
].join(' ');
KapyMenuAction(
value: 'split',
label: canSplit ? 'Split view' : splitBlocker ?? 'Split view',
icon: KapyIcons.viewColumnOutlined,
hint: canSplit
? widget.shortcuts
.bindingFor(ShortcutAction.splitEditor)
?.displayLabel
: null,
enabled: canSplit,
),
if (_pinToggle != null)
KapyMenuAction(
value: 'on-top',
label: alwaysOnTop ? 'Stop keeping on top' : 'Keep on top',
icon: KapyIcons.layersRounded,
hint: _pinShortcut,
),
if (mayEdit && !_specialMode && !note.isShared)
const KapyMenuAction(
value: 'hide',
label: 'Move to Hidden Notes',
icon: hiddenIcon,
),
if (mayEdit && _archiveMode)
const KapyMenuAction(
value: 'restore',
label: 'Restore note',
icon: restoreIcon,
),
if (mayEdit && _hiddenMode)
const KapyMenuAction(
value: 'unhide',
label: 'Move to Notes',
icon: unhideIcon,
),
if (mayEdit)
KapyMenuAction(
value: _specialMode ? 'delete' : 'archive',
label: _specialMode ? 'Delete permanently' : 'Archive note',
icon: _specialMode ? deleteIcon : archiveIcon,
hint: removeShortcut,
destructive: true,
),
];
}

void _runPageAction(String action, Note? note) {
switch (action) {
case 'split':
_splitEditor();
case 'on-top':
_pinToggle?.call();
}
if (note == null) return;
switch (action) {
case 'hide':
unawaited(_hideNote(note.id));
case 'restore':
_restoreNote(note.id);
case 'unhide':
_unhideNote(note.id);
case 'archive':
_archiveNote(note.id);
case 'delete':
unawaited(_deleteNote(note.id));
}
}

Widget _buildWideWorkspace() {
Expand Down Expand Up @@ -2966,6 +3054,9 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
alwaysOnTop: widget.prefs.alwaysOnTop,
onToggleAlwaysOnTop: _pinToggle,
alwaysOnTopShortcut: _pinShortcut,
newNoteShortcut: widget.shortcuts
.bindingFor(ShortcutAction.newNote)
?.displayLabel,
updates: widget.updates,
),
),
Expand Down
Loading
Loading