images are now removable

This commit is contained in:
Kima 2024-05-05 21:53:39 +02:00
parent c9db496e59
commit f64b1360d9
3 changed files with 101 additions and 76 deletions

View File

@ -149,26 +149,31 @@ class NotesPageState extends State<NotesPage> with TickerProviderStateMixin {
CupertinoPageRoute( CupertinoPageRoute(
builder: (context) => NoteViewScreen(note: e))), builder: (context) => NoteViewScreen(note: e))),
) )
: Container( : GestureDetector(
height: MediaQuery.of(context).size.width / 2.42, onTap: () => Navigator.of(context, rootNavigator: true).push(
width: MediaQuery.of(context).size.width / 2.42, CupertinoPageRoute(
decoration: BoxDecoration( builder: (context) => NoteViewScreen(note: e))),
boxShadow: [ child: Container(
if (Provider.of<SettingsProvider>(context, listen: false) height: MediaQuery.of(context).size.width / 2.42,
.shadowEffect) width: MediaQuery.of(context).size.width / 2.42,
BoxShadow( decoration: BoxDecoration(
offset: const Offset(0, 21), boxShadow: [
blurRadius: 23.0, if (Provider.of<SettingsProvider>(context, listen: false)
color: Theme.of(context).shadowColor, .shadowEffect)
), BoxShadow(
], offset: const Offset(0, 21),
), blurRadius: 23.0,
child: ClipRRect( color: Theme.of(context).shadowColor,
borderRadius: BorderRadius.circular(16.0), ),
child: Image.memory( ],
const Base64Decoder().convert(e.content), ),
fit: BoxFit.cover, child: ClipRRect(
gaplessPlayback: true, borderRadius: BorderRadius.circular(16.0),
child: Image.memory(
const Base64Decoder().convert(e.content),
fit: BoxFit.cover,
gaplessPlayback: true,
),
), ),
), ),
), ),

View File

@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:refilc/api/providers/self_note_provider.dart'; import 'package:refilc/api/providers/self_note_provider.dart';
import 'package:refilc/models/self_note.dart'; import 'package:refilc/models/self_note.dart';
@ -8,6 +10,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart'; import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:markdown/markdown.dart' as md; import 'package:markdown/markdown.dart' as md;
import 'notes_screen.i18n.dart';
class NoteViewScreen extends StatefulWidget { class NoteViewScreen extends StatefulWidget {
const NoteViewScreen({super.key, required this.note}); const NoteViewScreen({super.key, required this.note});
@ -30,7 +33,9 @@ class NoteViewScreenState extends State<NoteViewScreen> {
surfaceTintColor: Theme.of(context).scaffoldBackgroundColor, surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
leading: BackButton(color: AppColors.of(context).text), leading: BackButton(color: AppColors.of(context).text),
title: Text( title: Text(
widget.note.title ?? '${widget.note.content.split(' ')[0]}...', widget.note.noteType == NoteType.text
? (widget.note.title ?? '${widget.note.content.split(' ')[0]}...')
: 'image_note'.i18n,
style: TextStyle( style: TextStyle(
color: AppColors.of(context).text, color: AppColors.of(context).text,
fontSize: 26.0, fontSize: 26.0,
@ -38,52 +43,55 @@ class NoteViewScreenState extends State<NoteViewScreen> {
), ),
), ),
actions: [ actions: [
ClipRRect( if (widget.note.noteType == NoteType.text)
borderRadius: BorderRadius.circular(10.1), ClipRRect(
child: GestureDetector( borderRadius: BorderRadius.circular(10.1),
onTap: () { child: GestureDetector(
// handle tap onTap: () {
Navigator.of(context, rootNavigator: true).push( // handle tap
CupertinoPageRoute( Navigator.of(context, rootNavigator: true).push(
builder: (context) => CupertinoPageRoute(
AddNoteScreen(initialNote: widget.note))); builder: (context) =>
}, AddNoteScreen(initialNote: widget.note)));
child: Container( },
color: Theme.of(context).colorScheme.secondary.withOpacity(0.2), child: Container(
child: Padding( color:
padding: const EdgeInsets.all(8.0), Theme.of(context).colorScheme.secondary.withOpacity(0.2),
child: Stack( child: Padding(
children: [ padding: const EdgeInsets.all(8.0),
IconTheme( child: Stack(
data: IconThemeData( children: [
color: Theme.of(context).colorScheme.secondary, IconTheme(
data: IconThemeData(
color: Theme.of(context).colorScheme.secondary,
),
child: const Icon(
FeatherIcons.edit,
size: 20.0,
),
), ),
child: const Icon( IconTheme(
FeatherIcons.edit, data: IconThemeData(
size: 20.0, color:
Theme.of(context).brightness == Brightness.light
? Colors.black.withOpacity(.5)
: Colors.white.withOpacity(.3),
),
child: const Icon(
FeatherIcons.edit,
size: 20.0,
),
), ),
), ],
IconTheme( ),
data: IconThemeData(
color:
Theme.of(context).brightness == Brightness.light
? Colors.black.withOpacity(.5)
: Colors.white.withOpacity(.3),
),
child: const Icon(
FeatherIcons.edit,
size: 20.0,
),
),
],
), ),
), ),
), ),
), ),
), if (widget.note.noteType == NoteType.text)
const SizedBox( const SizedBox(
width: 10, width: 10,
), ),
ClipRRect( ClipRRect(
borderRadius: BorderRadius.circular(10.1), borderRadius: BorderRadius.circular(10.1),
child: GestureDetector( child: GestureDetector(
@ -140,21 +148,30 @@ class NoteViewScreenState extends State<NoteViewScreen> {
child: Column( child: Column(
children: [ children: [
Expanded( Expanded(
child: MarkdownBody( child: widget.note.noteType == NoteType.text
data: widget.note.content, ? MarkdownBody(
extensionSet: md.ExtensionSet( data: widget.note.content,
md.ExtensionSet.gitHubFlavored.blockSyntaxes, extensionSet: md.ExtensionSet(
<md.InlineSyntax>[ md.ExtensionSet.gitHubFlavored.blockSyntaxes,
md.EmojiSyntax(), <md.InlineSyntax>[
...md.ExtensionSet.gitHubFlavored.inlineSyntaxes md.EmojiSyntax(),
], ...md.ExtensionSet.gitHubFlavored.inlineSyntaxes
), ],
styleSheet: MarkdownStyleSheet( ),
p: const TextStyle( styleSheet: MarkdownStyleSheet(
fontSize: 15.0, p: const TextStyle(
), fontSize: 15.0,
), ),
), ),
)
: ClipRRect(
borderRadius: BorderRadius.circular(10.0),
child: Image.memory(
const Base64Decoder().convert(widget.note.content),
fit: BoxFit.contain,
gaplessPlayback: true,
),
),
), ),
// Expanded( // Expanded(
// child: Text( // child: Text(

View File

@ -18,6 +18,7 @@ extension SettingsLocalization on String {
"click_here": "Click here", "click_here": "Click here",
"select_image": "to select an image", "select_image": "to select an image",
"new_image": "New Image", "new_image": "New Image",
"image_note": "Image",
}, },
"hu_hu": { "hu_hu": {
"notes": "Füzet", "notes": "Füzet",
@ -34,6 +35,7 @@ extension SettingsLocalization on String {
"click_here": "Kattints ide", "click_here": "Kattints ide",
"select_image": "kép kiválasztásához", "select_image": "kép kiválasztásához",
"new_image": "Új kép", "new_image": "Új kép",
"image_note": "Kép",
}, },
"de_de": { "de_de": {
"notes": "Broschüre", "notes": "Broschüre",
@ -50,6 +52,7 @@ extension SettingsLocalization on String {
"click_here": "Klicken Sie hier", "click_here": "Klicken Sie hier",
"select_image": "um ein Bild auszuwählen", "select_image": "um ein Bild auszuwählen",
"new_image": "Neues Bild", "new_image": "Neues Bild",
"image_note": "Bild",
}, },
}; };