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(
builder: (context) => NoteViewScreen(note: e))),
)
: Container(
height: MediaQuery.of(context).size.width / 2.42,
width: MediaQuery.of(context).size.width / 2.42,
decoration: BoxDecoration(
boxShadow: [
if (Provider.of<SettingsProvider>(context, listen: false)
.shadowEffect)
BoxShadow(
offset: const Offset(0, 21),
blurRadius: 23.0,
color: Theme.of(context).shadowColor,
),
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(16.0),
child: Image.memory(
const Base64Decoder().convert(e.content),
fit: BoxFit.cover,
gaplessPlayback: true,
: GestureDetector(
onTap: () => Navigator.of(context, rootNavigator: true).push(
CupertinoPageRoute(
builder: (context) => NoteViewScreen(note: e))),
child: Container(
height: MediaQuery.of(context).size.width / 2.42,
width: MediaQuery.of(context).size.width / 2.42,
decoration: BoxDecoration(
boxShadow: [
if (Provider.of<SettingsProvider>(context, listen: false)
.shadowEffect)
BoxShadow(
offset: const Offset(0, 21),
blurRadius: 23.0,
color: Theme.of(context).shadowColor,
),
],
),
child: ClipRRect(
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:refilc/api/providers/self_note_provider.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:provider/provider.dart';
import 'package:markdown/markdown.dart' as md;
import 'notes_screen.i18n.dart';
class NoteViewScreen extends StatefulWidget {
const NoteViewScreen({super.key, required this.note});
@ -30,7 +33,9 @@ class NoteViewScreenState extends State<NoteViewScreen> {
surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
leading: BackButton(color: AppColors.of(context).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(
color: AppColors.of(context).text,
fontSize: 26.0,
@ -38,52 +43,55 @@ class NoteViewScreenState extends State<NoteViewScreen> {
),
),
actions: [
ClipRRect(
borderRadius: BorderRadius.circular(10.1),
child: GestureDetector(
onTap: () {
// handle tap
Navigator.of(context, rootNavigator: true).push(
CupertinoPageRoute(
builder: (context) =>
AddNoteScreen(initialNote: widget.note)));
},
child: Container(
color: Theme.of(context).colorScheme.secondary.withOpacity(0.2),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Stack(
children: [
IconTheme(
data: IconThemeData(
color: Theme.of(context).colorScheme.secondary,
if (widget.note.noteType == NoteType.text)
ClipRRect(
borderRadius: BorderRadius.circular(10.1),
child: GestureDetector(
onTap: () {
// handle tap
Navigator.of(context, rootNavigator: true).push(
CupertinoPageRoute(
builder: (context) =>
AddNoteScreen(initialNote: widget.note)));
},
child: Container(
color:
Theme.of(context).colorScheme.secondary.withOpacity(0.2),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Stack(
children: [
IconTheme(
data: IconThemeData(
color: Theme.of(context).colorScheme.secondary,
),
child: const Icon(
FeatherIcons.edit,
size: 20.0,
),
),
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,
),
),
),
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,
),
),
],
],
),
),
),
),
),
),
const SizedBox(
width: 10,
),
if (widget.note.noteType == NoteType.text)
const SizedBox(
width: 10,
),
ClipRRect(
borderRadius: BorderRadius.circular(10.1),
child: GestureDetector(
@ -140,21 +148,30 @@ class NoteViewScreenState extends State<NoteViewScreen> {
child: Column(
children: [
Expanded(
child: MarkdownBody(
data: widget.note.content,
extensionSet: md.ExtensionSet(
md.ExtensionSet.gitHubFlavored.blockSyntaxes,
<md.InlineSyntax>[
md.EmojiSyntax(),
...md.ExtensionSet.gitHubFlavored.inlineSyntaxes
],
),
styleSheet: MarkdownStyleSheet(
p: const TextStyle(
fontSize: 15.0,
),
),
),
child: widget.note.noteType == NoteType.text
? MarkdownBody(
data: widget.note.content,
extensionSet: md.ExtensionSet(
md.ExtensionSet.gitHubFlavored.blockSyntaxes,
<md.InlineSyntax>[
md.EmojiSyntax(),
...md.ExtensionSet.gitHubFlavored.inlineSyntaxes
],
),
styleSheet: MarkdownStyleSheet(
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(
// child: Text(

View File

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