Skip to content

Commit

Permalink
now note list also support markdown content
Browse files Browse the repository at this point in the history
  • Loading branch information
shukebeta committed Jul 7, 2024
1 parent 7b159c8 commit 2d0c7b3
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions lib/screens/components/note_list_item.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';

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

class NoteListItem extends StatelessWidget {
final Note note;
final VoidCallback onTap;
final VoidCallback? onDoubleTap; // onDoubleTap callback is optional
final VoidCallback? onDoubleTap;

const NoteListItem({
Key? key,
Expand All @@ -18,7 +19,7 @@ class NoteListItem extends StatelessWidget {
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
onDoubleTap: onDoubleTap, // Call onDoubleTap callback when double-tapped
onDoubleTap: onDoubleTap,
child: Container(
color: Colors.transparent,
child: Padding(
Expand All @@ -28,27 +29,27 @@ class NoteListItem extends StatelessWidget {
title: Row(
children: [
Expanded(
child: RichText(
child: note.isMarkdown
? MarkdownBody(
data: note.content + (note.isLong ? '...more' : ''),
styleSheet: MarkdownStyleSheet(
p: TextStyle(
fontStyle: note.isPrivate ? FontStyle.italic : FontStyle.normal,
fontSize: 20,
height: 1.6,
color: Colors.black,
),
),
)
: RichText(
text: TextSpan(
text: note.isLong ? '${note.content}... ' : note.content,
text: note.content + (note.isLong ? '...more' : ''),
style: TextStyle(
fontStyle: note.isPrivate ? FontStyle.italic : FontStyle.normal,
fontSize: 20,
height: 1.6,
color: Colors.black,
),
children: note.isLong
? [
const TextSpan(
text: 'more',
style: TextStyle(
fontWeight: FontWeight.normal,
color: Colors.blue,
decoration: TextDecoration.underline,
),
)
]
: [],
),
),
),
Expand Down

0 comments on commit 2d0c7b3

Please sign in to comment.