Skip to content

Commit

Permalink
use different backgrund color to indicate a private note, add visual …
Browse files Browse the repository at this point in the history
…separator between notes in a day
  • Loading branch information
shukebeta committed May 27, 2024
1 parent add6daf commit 79c5c69
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 43 deletions.
31 changes: 20 additions & 11 deletions lib/components/note_list.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../entities/note.dart';
import 'note_list_item.dart';
import 'package:intl/intl.dart';

import '../entities/note.dart';
import 'note_list_item.dart';

class NoteList extends StatelessWidget {
final List<Note> notes;
final Function(int) onTap;
Expand Down Expand Up @@ -42,7 +44,7 @@ class NoteList extends StatelessWidget {
// Date header
Padding(
padding:
const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
child: Align(
alignment: Alignment.center,
child: Text(
Expand All @@ -54,15 +56,22 @@ class NoteList extends StatelessWidget {
),
),
),
// List of notes for that date
// List of notes for that date with dividers
...dayNotes
.map((note) => NoteListItem(
note: note,
onTap: () => onTap(note.id),
onDoubleTap: onDoubleTap != null
? () => onDoubleTap!(note.id)
: null,
))
.asMap()
.entries
.map((entry) => Column(
children: [
NoteListItem(
note: entry.value,
onTap: () => onTap(entry.value.id),
onDoubleTap: onDoubleTap != null
? () => onDoubleTap!(entry.value.id)
: null,
),
if (entry.key < dayNotes.length - 1) const Divider(),
],
))
.toList(),
],
);
Expand Down
62 changes: 30 additions & 32 deletions lib/components/note_list_item.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import '../../entities/note.dart';

import '../entities/note.dart';

class NoteListItem extends StatelessWidget {
final Note note;
Expand All @@ -18,40 +19,37 @@ class NoteListItem extends StatelessWidget {
return GestureDetector(
onTap: onTap,
onDoubleTap: onDoubleTap, // Call onDoubleTap callback when double-tapped
child: ListTile(
title: Row(
children: [
Expanded(
child: RichText(
text: TextSpan(
text: note.isLong ? '${note.content}... ' : note.content,
style: TextStyle(
fontStyle: note.isPrivate ? FontStyle.italic : FontStyle.normal,
fontSize: 20,
color: Colors.black,
child: Container(
color: note.isPrivate ? Colors.grey.shade200 : Colors.transparent,
child: ListTile(
title: Row(
children: [
Expanded(
child: RichText(
text: TextSpan(
text: note.isLong ? '${note.content}... ' : note.content,
style: TextStyle(
fontStyle: note.isPrivate ? FontStyle.italic : FontStyle.normal,
fontSize: 20,
color: Colors.black,
),
children: note.isLong
? [
const TextSpan(
text: 'more',
style: TextStyle(
fontWeight: FontWeight.normal,
color: Colors.blue,
decoration: TextDecoration.underline,
),
)
]
: [],
),
children: note.isLong
? [
const TextSpan(
text: 'more',
style: TextStyle(
fontWeight: FontWeight.normal,
color: Colors.blue,
decoration: TextDecoration.underline,
),
)
]
: [],
),
),
),
if (note.isPrivate)
const Icon(
Icons.lock,
size: 16.0,
color: Colors.grey,
),
],
],
),
),
),
);
Expand Down

0 comments on commit 79c5c69

Please sign in to comment.