Skip to content

Commit

Permalink
chore: remove unnecessary selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkrieger committed Apr 12, 2024
1 parent 58b69f4 commit 238bb0e
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions lib/views/notes_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:provider/provider.dart';
import 'package:scroll_to_index/scroll_to_index.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:timeago_flutter/timeago_flutter.dart';
import 'package:voice_outliner/data/outline.dart';
import 'package:voice_outliner/repositories/db_repository.dart';
import 'package:voice_outliner/state/notes_state.dart';
import 'package:voice_outliner/state/outline_state.dart';
Expand Down Expand Up @@ -277,21 +278,10 @@ class _NotesViewState extends State<_NotesView> {

Widget buildChild(BuildContext context) {
final outlineId = widget.args.outlineId;
final currentOutlineName = context.select<OutlinesModel, String>((value) =>
value.outlines
.firstWhere((element) => element.id == outlineId,
orElse: () => defaultOutline)
.name);
final currentOutlineEmoji = context.select<OutlinesModel, String>((value) =>
value.outlines
.firstWhere((element) => element.id == outlineId,
orElse: () => defaultOutline)
.emoji);
final currentOutlineArchived = context.select<OutlinesModel, bool>(
(value) => value.outlines
.firstWhere((element) => element.id == outlineId,
orElse: () => defaultOutline)
.archived);
final currentOutline = context.select<OutlinesModel, Outline>((value) =>
value.outlines.firstWhere((element) => element.id == outlineId,
orElse: () => defaultOutline));

final noteCount =
context.select<NotesModel, int>((value) => value.notes.length);
final scrollController = context.select<NotesModel, AutoScrollController>(
Expand All @@ -313,7 +303,7 @@ class _NotesViewState extends State<_NotesView> {
onTap: () => _handleMenu("rename"),
borderRadius: const BorderRadius.all(Radius.circular(5.0)),
child: Text(
"$currentOutlineEmoji $currentOutlineName",
"${currentOutline.emoji} ${currentOutline.name}",
overflow: TextOverflow.fade,
)),
),
Expand All @@ -322,7 +312,7 @@ class _NotesViewState extends State<_NotesView> {
onPressed: _goToOutlines,
icon: const Icon(Icons.chevron_left)),
actions: [
if (currentOutlineArchived)
if (currentOutline.archived)
IconButton(
tooltip: "currently archived - unarchive?",
icon: const Icon(Icons.unarchive),
Expand Down Expand Up @@ -370,7 +360,7 @@ class _NotesViewState extends State<_NotesView> {
Opacity(
opacity: 0.5,
child: Text(
currentOutlineEmoji,
currentOutline.emoji,
style: const TextStyle(fontSize: 80.0),
textAlign: TextAlign.center,
)),
Expand Down

0 comments on commit 238bb0e

Please sign in to comment.