Skip to content

Commit

Permalink
Add drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Jan 13, 2024
1 parent 03f7540 commit 7c5c4c3
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 40 deletions.
2 changes: 1 addition & 1 deletion api/lib/models/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ part 'model.freezed.dart';

const kColorBlack = 0xFF000000;

abstract class DescriptiveModel {
mixin DescriptiveModel {
Multihash? get id;
String get name;
String get description;
Expand Down
25 changes: 10 additions & 15 deletions api/lib/models/note/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,15 @@ enum NoteStatus {
}

extension NoteStatusExtension on NoteStatus {
bool? get done {
switch (this) {
case NoteStatus.todo:
return false;
case NoteStatus.inProgress:
return null;
case NoteStatus.done:
return true;
}
}
bool? get done => switch (this) {
NoteStatus.todo => false,
NoteStatus.inProgress => null,
NoteStatus.done => true,
};

static NoteStatus fromDone(bool? done) {
if (done == null) return NoteStatus.inProgress;
if (done) return NoteStatus.done;
return NoteStatus.todo;
}
static NoteStatus fromDone(bool? done) => switch (done) {
true => NoteStatus.done,
false => NoteStatus.todo,
null => NoteStatus.inProgress,
};
}
2 changes: 1 addition & 1 deletion api/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: A starting point for Dart libraries or applications.
# homepage: https://www.example.com

environment:
sdk: '>=2.17.0 <3.0.0'
sdk: ">=3.0.0 <4.0.0"

dependencies:
meta: ^1.9.1
Expand Down
3 changes: 2 additions & 1 deletion app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,6 @@
"compact": "Compact",
"comfortable": "Comfortable",
"standard": "Standard",
"highContrast": "High contrast"
"highContrast": "High contrast",
"labels": "Labels"
}
48 changes: 48 additions & 0 deletions app/lib/pages/notes/navigator/drawer.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import 'package:flow/cubits/flow.dart';
import 'package:flow/helpers/sourced_paging_controller.dart';
import 'package:flow/pages/notes/label.dart';
import 'package:flow/widgets/builder_delegate.dart';
import 'package:flow/widgets/color.dart';
import 'package:flow_api/models/label/model.dart';
import 'package:flow_api/models/model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import 'package:lib5/lib5.dart';
import 'package:material_leap/material_leap.dart';
import 'package:phosphor_flutter/phosphor_flutter.dart';

part 'labels.dart';

class NotesNavigatorDrawer extends StatelessWidget {
final Multihash? selectedLabel;
final LabelChangedCallback? onLabelChanged;

const NotesNavigatorDrawer({
super.key,
this.selectedLabel,
this.onLabelChanged,
});

@override
Widget build(BuildContext context) {
return ListView(
children: [
ExpansionPanelList.radio(
children: [
ExpansionPanel(
headerBuilder: (context, isExpanded) => ListTile(
title: Text(AppLocalizations.of(context).labels),
),
body: _NoteLabelsView(
onChanged: onLabelChanged,
selected: selectedLabel,
),
),
],
),
],
);
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
import 'package:flow/helpers/sourced_paging_controller.dart';
import 'package:flow/widgets/builder_delegate.dart';
import 'package:flow/widgets/color.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import 'package:lib5/lib5.dart';
import 'package:phosphor_flutter/phosphor_flutter.dart';
import 'package:flow_api/models/label/model.dart';
import 'package:flow_api/models/model.dart';
part of 'drawer.dart';

import '../../cubits/flow.dart';
import 'label.dart';
typedef LabelChangedCallback = void Function(SourcedModel<Label>, bool);

class LabelsDrawer extends StatefulWidget {
class _NoteLabelsView extends StatefulWidget {
final Multihash? selected;
final void Function(SourcedModel<Label>, bool)? onChanged;
final LabelChangedCallback? onChanged;

const LabelsDrawer({super.key, this.selected, this.onChanged});
const _NoteLabelsView({super.key, this.selected, this.onChanged});

@override
State<LabelsDrawer> createState() => _LabelsDrawerState();
State<_NoteLabelsView> createState() => _NoteLabelsViewState();
}

class _LabelsDrawerState extends State<LabelsDrawer> {
class _NoteLabelsViewState extends State<_NoteLabelsView> {
late final SourcedPagingController<Label> _pagingController;
String _search = '';
late final FlowCubit _cubit;
Expand All @@ -46,7 +35,7 @@ class _LabelsDrawerState extends State<LabelsDrawer> {
}

@override
void didUpdateWidget(covariant LabelsDrawer oldWidget) {
void didUpdateWidget(covariant _NoteLabelsView oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.selected != widget.selected) {
setState(() {});
Expand Down
4 changes: 2 additions & 2 deletions app/lib/pages/notes/page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:typed_data';

import 'package:flow/pages/notes/card.dart';
import 'package:flow/pages/notes/labels.dart';
import 'package:flow/pages/notes/navigator/drawer.dart';
import 'package:flow/pages/notes/note.dart';
import 'package:flow/widgets/builder_delegate.dart';
import 'package:flow/widgets/navigation.dart';
Expand Down Expand Up @@ -46,7 +46,7 @@ class _NotesPageState extends State<NotesPage> {
Widget build(BuildContext context) {
return FlowNavigation(
title: AppLocalizations.of(context).notes,
endDrawer: LabelsDrawer(
endDrawer: NotesNavigatorDrawer(
selected: _filter.selectedLabel,
onChanged: (value, add) {
final source = value.source;
Expand Down
2 changes: 1 addition & 1 deletion tools/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flow_tools
environment:
sdk: ">=2.13.0 <3.0.0"
sdk: ">=3.0.0 <4.0.0"
dependencies:
args: ^2.4.2
intl: ^0.19.0
Expand Down

0 comments on commit 7c5c4c3

Please sign in to comment.