Skip to content

Commit

Permalink
Merge pull request #44 from xsoulspace/idea-note-improvements
Browse files Browse the repository at this point in the history
Idea note improvements
  • Loading branch information
Arenukvern authored Oct 22, 2021
2 parents 4a87a09 + ff15da4 commit 3ff75c9
Show file tree
Hide file tree
Showing 17 changed files with 253 additions and 179 deletions.
79 changes: 40 additions & 39 deletions lib/abstract/abstract.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions lib/abstract/idea_project/idea_project.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ class IdeaProject extends BasicProject with EquatableMixin {
id: createId(),
title: title,
);
final ideaBox = Hive.box<IdeaProject>(HiveBoxesIds.ideaProjectKey);
final ideaAnswersBox =
Hive.box<IdeaProjectAnswer>(HiveBoxesIds.ideaProjectAnswerKey);
final ideaBox =
await Hive.openBox<IdeaProject>(HiveBoxesIds.ideaProjectKey);
final ideaAnswersBox = await Hive.openBox<IdeaProjectAnswer>(
HiveBoxesIds.ideaProjectAnswerKey,
);
await ideaBox.put(idea.id, idea);
idea.answers = HiveList(ideaAnswersBox);
idea.answers = HiveList<IdeaProjectAnswer>(ideaAnswersBox);
return idea;
}

Expand Down
20 changes: 15 additions & 5 deletions lib/abstract/note_project/note_project.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ typedef NoteProjectId = String;
class NoteProject extends BasicProject {
NoteProject({
required final String id,
required final String title,
required final DateTime created,
required final DateTime updated,
final this.note = '',
final bool isCompleted = defaultProjectIsCompleted,
}) : super(
created: created,
id: id,
title: title,
isCompleted: isCompleted,
updated: updated,
title: '',
);
static Future<NoteProject> create({
required final String title,
Expand All @@ -26,14 +25,25 @@ class NoteProject extends BasicProject {
updated: created,
created: created,
id: createId(),
title: title,
);
await Hive.box<NoteProject>(HiveBoxesIds.noteProjectKey).put(note.id, note);
final box = await Hive.openBox<NoteProject>(HiveBoxesIds.noteProjectKey);
await box.put(note.id, note);
return note;
}

@override
String toShareString() => '$title \n $note';
@JsonKey(ignore: true)
String get title {
if (note.length <= 90) return note;
return note.substring(0, 90);
}

/// title setter not needed to be implemented.
@override
set title(final String _) => throw UnimplementedError();

@override
String toShareString() => note;

@HiveField(projectLatestFieldHiveId + 1)
String note;
Expand Down
16 changes: 16 additions & 0 deletions lib/library/widgets/icon_idea_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,19 @@ class IconIdeaButton extends StatelessWidget {
);
}
}

class IconIdea extends StatelessWidget {
const IconIdea({
final this.size = 24.0,
final Key? key,
}) : super(key: key);
final double size;
@override
Widget build(final BuildContext context) {
return Assets.icons.idea.svg(
height: size,
width: size,
color: Theme.of(context).textTheme.bodyText2?.color?.withOpacity(0.5),
);
}
}
Loading

0 comments on commit 3ff75c9

Please sign in to comment.