Skip to content

Commit

Permalink
feat: higher info density in entry cards, fix tag parsing, spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatNerdSquared committed Jan 21, 2024
1 parent 79338c5 commit ff1c6bc
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 118 deletions.
2 changes: 1 addition & 1 deletion lib/format_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ List<String> findContacts(String input) {
}

String stripTagOnlyLines(String input) {
var items = input.split('\n');
var items = input.trim().split('\n');
if (items.last.replaceAll(RegExp(r'#[^\s]+'), '').replaceAll(' ', '') == '') {
items.removeLast();
return items.join('\n');
Expand Down
20 changes: 12 additions & 8 deletions lib/widgets/peregrine_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class PeregrineAppBar extends ConsumerWidget {
size: 20,
),
const Padding(
padding: EdgeInsets.only(right: PretConfig.thinElementSpacing)),
padding: EdgeInsets.only(right: PretConfig.thinElementSpacing),
),
Expanded(
flex: 2,
child: Text(
Expand All @@ -48,9 +49,10 @@ class PeregrineAppBar extends ConsumerWidget {
)),
IconButton.filled(
style: IconButton.styleFrom(
iconSize: 20,
minimumSize: const Size(36, 36),
maximumSize: const Size(36, 36),
iconSize: 18,
padding: const EdgeInsets.all(PretConfig.minElementSpacing),
minimumSize: const Size(30, 30),
maximumSize: const Size(30, 30),
backgroundColor: const Color(0xffdac6b0),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(PretConfig.thinBorderRounding),
Expand All @@ -62,12 +64,14 @@ class PeregrineAppBar extends ConsumerWidget {
),
),
const Padding(
padding: EdgeInsets.only(right: PretConfig.thinElementSpacing)),
padding: EdgeInsets.only(right: PretConfig.minElementSpacing),
),
IconButton.filled(
style: IconButton.styleFrom(
iconSize: 20,
minimumSize: const Size(36, 36),
maximumSize: const Size(36, 36),
iconSize: 18,
minimumSize: const Size(30, 30),
maximumSize: const Size(30, 30),
padding: const EdgeInsets.all(PretConfig.minElementSpacing),
backgroundColor: const Color(0xffdac6b0),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(PretConfig.thinBorderRounding),
Expand Down
203 changes: 94 additions & 109 deletions lib/widgets/peregrine_entry_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,120 +27,105 @@ class PeregrineEntryCard extends ConsumerWidget {
right: PretConfig.preserveShadowSpacing,
),
child: PretCard(
padding: const EdgeInsets.only(
padding: EdgeInsets.only(
top: PretConfig.thinElementSpacing,
left: PretConfig.defaultElementSpacing,
right: PretConfig.defaultElementSpacing,
bottom: PretConfig.defaultElementSpacing,
bottom: entry.isEncrypted && ref.watch(isLocked)
? PretConfig.thinElementSpacing
: PretConfig.defaultElementSpacing,
),
child: Padding(
padding: const EdgeInsets.only(top: PretConfig.thinElementSpacing),
// this row is useless, but taking it out gives a box drawing error,
// i think i'm doing something wrong
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.',
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.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(
style: const ButtonStyle(
minimumSize:
MaterialStatePropertyAll(
Size(32, 32),
),
visualDensity:
VisualDensity.compact,
shape: MaterialStatePropertyAll(
RoundedRectangleBorder(
borderRadius:
PretConfig.thinBorderRadius,
),
),
padding: MaterialStatePropertyAll(
EdgeInsets.all(
//PretConfig.minElementSpacing / 2,
PretConfig.minElementSpacing),
)),
onPressed: () => ref
.read(entryFilterProvider.notifier)
.setTagFilter(tag),
child: Text(
'#$tag',
)))
.toList()),
),
],
),
const Padding(
padding:
EdgeInsets.only(top: PretConfig.minElementSpacing),
),
...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(
color: Colors.grey,
fontSize: 16,
fontStyle: FontStyle.italic,
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,
),
),
]),
),
],
),
),
),
]),
),
]),
));
}
}

0 comments on commit ff1c6bc

Please sign in to comment.