Skip to content

Commit

Permalink
Improve note editing
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed May 9, 2024
1 parent d5caa30 commit 1a30d31
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 174 deletions.
4 changes: 2 additions & 2 deletions app/lib/pages/dashboard/notes.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:flow/pages/notes/card.dart';
import 'package:flow/pages/notes/tile.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Expand All @@ -20,7 +20,7 @@ class _DashboardNotesCardState extends State<DashboardNotesCard> {
final sources = context.read<FlowCubit>().getCurrentServicesMap();
final notes = <(Note, String)>[];
for (final source in sources.entries) {
notes.addAll((await source.value.note?.getNotes() ?? [])
notes.addAll((await source.value.note?.getNotes(limit: 5) ?? [])
.map((e) => (e, source.key))
.toList());
}
Expand Down
93 changes: 46 additions & 47 deletions app/lib/pages/dashboard/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,54 +18,53 @@ class _DashboardPageState extends State<DashboardPage> {
Widget build(BuildContext context) {
return FlowNavigation(
title: AppLocalizations.of(context).dashboard,
body: Align(
alignment: Alignment.topCenter,
child: Container(
constraints: const BoxConstraints(maxWidth: 1000),
child: LayoutBuilder(
builder: (context, constraints) {
return ListView(
children: [
Card(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: ConstrainedBox(
constraints: const BoxConstraints(
minHeight: 300,
minWidth: 300,
maxWidth: 600,
maxHeight: 600),
child: const ClockView(),
),
)),
Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
AppLocalizations.of(context).welcome,
style: Theme.of(context).textTheme.titleLarge,
textAlign: TextAlign.center,
),
)),
Wrap(
alignment: WrapAlignment.center,
children: [
const DashboardNotesCard(),
const DashboardEventsCard(),
]
.map((e) => ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 500),
child: Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: e,
)),
))
.toList(),
body: SingleChildScrollView(
child: Align(
alignment: Alignment.topCenter,
child: Container(
constraints: const BoxConstraints(maxWidth: 1000),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Card(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: ConstrainedBox(
constraints: const BoxConstraints(
minHeight: 300,
minWidth: 300,
maxWidth: 600,
maxHeight: 600),
child: const ClockView(),
),
],
);
},
)),
Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
AppLocalizations.of(context).welcome,
style: Theme.of(context).textTheme.titleLarge,
textAlign: TextAlign.center,
),
)),
Wrap(
alignment: WrapAlignment.center,
children: [
const DashboardNotesCard(),
const DashboardEventsCard(),
]
.map((e) => ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 500),
child: Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: e,
)),
))
.toList(),
),
],
),
),
),
),
Expand Down
1 change: 1 addition & 0 deletions app/lib/pages/notes/list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class NotesListView extends StatelessWidget {
(ctx, item, index) => NoteListTile(
note: item.model,
source: item.source,
controller: controller,
),
),
);
Expand Down
2 changes: 1 addition & 1 deletion app/lib/pages/notes/navigator/drawer.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flow/cubits/flow.dart';
import 'package:flow/helpers/sourced_paging_controller.dart';
import 'package:flow/pages/notes/card.dart';
import 'package:flow/pages/notes/tile.dart';
import 'package:flow/pages/notes/filter.dart';
import 'package:flow/pages/notes/label.dart';
import 'package:flow/pages/notes/notebook.dart';
Expand Down
3 changes: 2 additions & 1 deletion app/lib/pages/notes/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ class _NotesBodyViewState extends State<NotesBodyView> {
void didUpdateWidget(covariant NotesBodyView oldWidget) {
super.didUpdateWidget(oldWidget);

if (oldWidget.search != widget.search) {
if (oldWidget.search != widget.search ||
oldWidget.parent != widget.parent) {
_controller.refresh();
}
if (oldWidget.filter != widget.filter) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flow/helpers/sourced_paging_controller.dart';
import 'package:flow/widgets/markdown_field.dart';
import 'package:flow_api/models/note/model.dart';
import 'package:flutter/material.dart';
Expand All @@ -6,11 +7,13 @@ import 'package:go_router/go_router.dart';
class NoteListTile extends StatelessWidget {
final String source;
final Note note;
final SourcedPagingController<Note>? controller;

const NoteListTile({
super.key,
required this.source,
required this.note,
this.controller,
});

@override
Expand All @@ -25,14 +28,15 @@ class NoteListTile extends StatelessWidget {
),
title: Text(note.name),
subtitle: MarkdownText(note.description),
onTap: () {
GoRouter.of(context).pushNamed(
onTap: () async {
await GoRouter.of(context).pushNamed(
source.isEmpty ? "subnote-local" : "subnote",
pathParameters: {
if (source.isNotEmpty) "source": source,
"id": note.id!.toBase64Url(),
},
);
controller?.refresh();
},
);
}
Expand Down
187 changes: 93 additions & 94 deletions app/lib/pages/notes/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -325,105 +325,104 @@ class _NoteViewState extends State<NoteView> {
),
]),
),
const SizedBox(height: 16),
SizedBox(
height: 50,
child: Scrollbar(
controller: _formattingScrollController,
child: ListView(
controller: _formattingScrollController,
scrollDirection: Axis.horizontal,
children: [
...[
PhosphorIconsLight.textHOne,
PhosphorIconsLight.textHTwo,
PhosphorIconsLight.textHThree,
PhosphorIconsLight.textHFour,
PhosphorIconsLight.textHFive,
PhosphorIconsLight.textHSix
].mapIndexed((index, element) => IconButton(
icon: PhosphorIcon(element),
onPressed: () => _addDescription(
PastePositing.line,
"${"#" * (index + 1)} ",
),
)),
...[
(
'```',
PhosphorIconsLight.codeSimple,
AppLocalizations.of(context).codeBlock
),
(
'>',
PhosphorIconsLight.quotes,
AppLocalizations.of(context).quote
),
(
'- ',
PhosphorIconsLight.list,
AppLocalizations.of(context).list
),
(
'1. ',
PhosphorIconsLight.listNumbers,
AppLocalizations.of(context).numberedList
),
].map((e) => IconButton(
icon: PhosphorIcon(e.$2),
tooltip: e.$3,
onPressed: () => _addDescription(
PastePositing.line,
e.$1,
),
)),
const SizedBox(width: 8),
...[
(
'**',
PhosphorIconsLight.textB,
AppLocalizations.of(context).bold
),
(
'*',
PhosphorIconsLight.textItalic,
AppLocalizations.of(context).italic
),
(
'~~',
PhosphorIconsLight.textStrikethrough,
AppLocalizations.of(context).strikethrough
),
(
'`',
PhosphorIconsLight.code,
AppLocalizations.of(context).code
),
].map((e) => IconButton(
icon: PhosphorIcon(e.$2),
tooltip: e.$3,
onPressed: () => _addDescription(
PastePositing.selection,
e.$1,
),
)),
IconButton(
icon: const PhosphorIcon(PhosphorIconsLight.link),
tooltip: AppLocalizations.of(context).link,
onPressed: () => _addDescription(
PastePositing.selection,
'[',
']()',
),
),
]),
),
),
MarkdownField(
decoration: InputDecoration(
labelText: AppLocalizations.of(context).description,
border: const OutlineInputBorder(),
),
toolbar: SizedBox(
height: 50,
child: Scrollbar(
controller: _formattingScrollController,
child: ListView(
controller: _formattingScrollController,
scrollDirection: Axis.horizontal,
children: [
...[
PhosphorIconsLight.textHOne,
PhosphorIconsLight.textHTwo,
PhosphorIconsLight.textHThree,
PhosphorIconsLight.textHFour,
PhosphorIconsLight.textHFive,
PhosphorIconsLight.textHSix
].mapIndexed((index, element) => IconButton(
icon: PhosphorIcon(element),
onPressed: () => _addDescription(
PastePositing.line,
"${"#" * (index + 1)} ",
),
)),
...[
(
'```',
PhosphorIconsLight.codeSimple,
AppLocalizations.of(context).codeBlock
),
(
'>',
PhosphorIconsLight.quotes,
AppLocalizations.of(context).quote
),
(
'- ',
PhosphorIconsLight.list,
AppLocalizations.of(context).list
),
(
'1. ',
PhosphorIconsLight.listNumbers,
AppLocalizations.of(context).numberedList
),
].map((e) => IconButton(
icon: PhosphorIcon(e.$2),
tooltip: e.$3,
onPressed: () => _addDescription(
PastePositing.line,
e.$1,
),
)),
const SizedBox(width: 8),
...[
(
'**',
PhosphorIconsLight.textB,
AppLocalizations.of(context).bold
),
(
'*',
PhosphorIconsLight.textItalic,
AppLocalizations.of(context).italic
),
(
'~~',
PhosphorIconsLight.textStrikethrough,
AppLocalizations.of(context).strikethrough
),
(
'`',
PhosphorIconsLight.code,
AppLocalizations.of(context).code
),
].map((e) => IconButton(
icon: PhosphorIcon(e.$2),
tooltip: e.$3,
onPressed: () => _addDescription(
PastePositing.selection,
e.$1,
),
)),
IconButton(
icon: const PhosphorIcon(PhosphorIconsLight.link),
tooltip: AppLocalizations.of(context).link,
onPressed: () => _addDescription(
PastePositing.selection,
'[',
']()',
),
),
]),
),
),
controller: _descriptionController,
onChangeEnd: (value) {
_newNote = _newNote.copyWith(description: value);
Expand Down
Loading

0 comments on commit 1a30d31

Please sign in to comment.