Skip to content

Commit

Permalink
feat: move entry tags into same section as date
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatNerdSquared committed Jan 10, 2024
1 parent 4971c55 commit dad1d9c
Showing 1 changed file with 107 additions and 79 deletions.
186 changes: 107 additions & 79 deletions lib/widgets/peregrine_entry_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,89 +27,117 @@ class PeregrineEntryCard extends ConsumerWidget {
right: PretConfig.preserveShadowSpacing,
),
child: PretCard(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: entry.isEncrypted && ref.watch(isLocked)
? const Text.rich(TextSpan(text: '🔒', children: [
TextSpan(
text:
'This entry is encrypted. Unlock the app to view.',
style: TextStyle(
color: Colors.grey,
fontSize: 16,
fontStyle: FontStyle.italic,
),
)
]))
: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('${formatDate(entry.date)} '),
Text(formatTime(entry.date)),
],
padding: const EdgeInsets.only(
left: PretConfig.defaultElementSpacing,
right: PretConfig.defaultElementSpacing,
bottom: PretConfig.defaultElementSpacing,
),
child: Padding(
padding: const EdgeInsets.only(top: PretConfig.thinElementSpacing),
child: Row(
children: [
Expanded(
child: entry.isEncrypted && ref.watch(isLocked)
? const Text.rich(TextSpan(text: '🔒', children: [
TextSpan(
text:
'This entry is encrypted. Unlock the app to view.',
style: TextStyle(
color: Colors.grey,
fontSize: 16,
fontStyle: FontStyle.italic,
),
const Divider(),
...MarkdownGenerator(
generators: [latexGenerator],
inlineSyntaxList: [LatexSyntax()],
linesMargin: const EdgeInsets.all(0),
).buildWidgets(
stripTagOnlyLines(entry.input),
config: MarkdownConfig(configs: [
ImgConfig(builder: (url, attributes) {
if (url.contains(r'data:image/png;base64,')) {
return Image.memory(base64Decode(
url.replaceAll(
'data:image/png;base64,', '')));
} else {
return Image.network(url);
}
}),
const CodeConfig(
style: TextStyle(
fontFamily: 'Menlo',
backgroundColor: Color(0xffeff1f3),
)
]))
: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
children: [
Text('${formatDate(entry.date)} '),
Text(formatTime(entry.date)),
],
),
const Padding(
padding: EdgeInsets.all(
PretConfig.minElementSpacing)),
Expanded(
child: Wrap(
spacing: PretConfig.minElementSpacing,
runSpacing:
PretConfig.minElementSpacing,
alignment: WrapAlignment.end,
children: entry.tags
.map((tag) => OutlinedButton(
// color: Colors.pink[100]!,
style: const ButtonStyle(
visualDensity:
VisualDensity.compact,
shape:
MaterialStatePropertyAll(
RoundedRectangleBorder(
borderRadius: PretConfig
.thinBorderRadius,
),
),
padding:
MaterialStatePropertyAll(
EdgeInsets.all(
PretConfig
.minElementSpacing /
2,
),
)),
onPressed: () => ref
.read(entryFilterProvider
.notifier)
.setTagFilter(tag),
child: Text(
'#$tag',
)))
.toList()),
),
],
),
const Divider(),
...MarkdownGenerator(
generators: [latexGenerator],
inlineSyntaxList: [LatexSyntax()],
linesMargin: const EdgeInsets.all(0),
).buildWidgets(
stripTagOnlyLines(entry.input),
config: MarkdownConfig(configs: [
ImgConfig(builder: (url, attributes) {
if (url
.contains(r'data:image/png;base64,')) {
return Image.memory(base64Decode(
url.replaceAll(
'data:image/png;base64,', '')));
} else {
return Image.network(url);
}
}),
const CodeConfig(
style: TextStyle(
fontFamily: 'Menlo',
backgroundColor: Color(0xffeff1f3),
),
),
]),
),
const Padding(
padding: EdgeInsets.only(
top: PretConfig.minElementSpacing,
),
]),
),
const Padding(
padding: EdgeInsets.only(
top: PretConfig.minElementSpacing,
),
),
Wrap(
spacing: PretConfig.minElementSpacing,
runSpacing: PretConfig.minElementSpacing,
children: entry.tags
.map((tag) => OutlinedButton(
// color: Colors.pink[100]!,
style: const ButtonStyle(
shape: MaterialStatePropertyAll(
RoundedRectangleBorder(
borderRadius:
PretConfig.thinBorderRadius,
),
),
padding: MaterialStatePropertyAll(
EdgeInsets.all(
PretConfig.minElementSpacing,
),
)),
onPressed: () => ref
.read(entryFilterProvider.notifier)
.setTagFilter(tag),
child: Text('#$tag')))
.toList())
]),
),
],
]),
),
],
),
),
));
}
Expand Down

0 comments on commit dad1d9c

Please sign in to comment.