outsource filename and doc name in struct
This commit is contained in:
parent
5bb5e0e539
commit
3e46750669
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import 'canvas/document_types.dart';
|
||||||
import 'canvas/drawing_page.dart';
|
import 'canvas/drawing_page.dart';
|
||||||
import 'context/file_change_notifier.dart';
|
import 'context/file_change_notifier.dart';
|
||||||
import 'pages/all_notes_page.dart';
|
import 'pages/all_notes_page.dart';
|
||||||
@ -58,8 +59,7 @@ class _AppState extends State<App> {
|
|||||||
ctx,
|
ctx,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (ctx) => DrawingPage(
|
builder: (ctx) => DrawingPage(
|
||||||
filePath: filename,
|
meta: NoteMetaData(filename, name),
|
||||||
name: name,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
).then((v) => notifier.loadAllNotes());
|
).then((v) => notifier.loadAllNotes());
|
||||||
|
@ -45,3 +45,10 @@ class Point {
|
|||||||
|
|
||||||
Point(this.point, this.thickness);
|
Point(this.point, this.thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class NoteMetaData {
|
||||||
|
final String name;
|
||||||
|
final String filePath;
|
||||||
|
|
||||||
|
NoteMetaData(this.name, this.filePath);
|
||||||
|
}
|
||||||
|
@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
|
|||||||
import '../savesystem/note_file.dart';
|
import '../savesystem/note_file.dart';
|
||||||
import '../widgets/drawing_page_top_actions.dart';
|
import '../widgets/drawing_page_top_actions.dart';
|
||||||
import '../widgets/tool_bar.dart';
|
import '../widgets/tool_bar.dart';
|
||||||
|
import 'document_types.dart';
|
||||||
import 'my_painter.dart';
|
import 'my_painter.dart';
|
||||||
import 'paint_controller.dart';
|
import 'paint_controller.dart';
|
||||||
import 'screen_document_mapping.dart';
|
import 'screen_document_mapping.dart';
|
||||||
@ -13,11 +14,9 @@ import 'screen_document_mapping.dart';
|
|||||||
/// Handles input events and draws canvas element
|
/// Handles input events and draws canvas element
|
||||||
class DrawingPage extends StatefulWidget {
|
class DrawingPage extends StatefulWidget {
|
||||||
// path to the .dbnote file
|
// path to the .dbnote file
|
||||||
final String filePath;
|
final NoteMetaData meta;
|
||||||
final String name;
|
|
||||||
|
|
||||||
const DrawingPage({Key? key, required this.filePath, required this.name})
|
const DrawingPage({Key? key, required this.meta}) : super(key: key);
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<DrawingPage> createState() => _DrawingPageState();
|
State<DrawingPage> createState() => _DrawingPageState();
|
||||||
@ -29,7 +28,7 @@ class _DrawingPageState extends State<DrawingPage> {
|
|||||||
Offset offset = const Offset(.0, .0);
|
Offset offset = const Offset(.0, .0);
|
||||||
|
|
||||||
late PaintController controller;
|
late PaintController controller;
|
||||||
late NoteFile noteFile = NoteFile(widget.filePath);
|
late NoteFile noteFile = NoteFile(widget.meta.filePath);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -57,9 +56,10 @@ class _DrawingPageState extends State<DrawingPage> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
backgroundColor: Colors.blueGrey,
|
backgroundColor: Colors.blueGrey,
|
||||||
title: Text(widget.name),
|
title: Text(widget.meta.name),
|
||||||
actions: [
|
actions: [
|
||||||
DrawingPageTopActions(controller: controller, noteName: widget.name)
|
DrawingPageTopActions(
|
||||||
|
controller: controller, noteMetaData: widget.meta)
|
||||||
]),
|
]),
|
||||||
body: Row(
|
body: Row(
|
||||||
children: [
|
children: [
|
||||||
|
@ -4,16 +4,17 @@ import 'package:fluentui_system_icons/fluentui_system_icons.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:fluttertoast/fluttertoast.dart';
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
|
||||||
|
import '../canvas/document_types.dart';
|
||||||
import '../canvas/paint_controller.dart';
|
import '../canvas/paint_controller.dart';
|
||||||
import '../export/export_pdf.dart';
|
import '../export/export_pdf.dart';
|
||||||
import 'icon_material_button.dart';
|
import 'icon_material_button.dart';
|
||||||
|
|
||||||
class DrawingPageTopActions extends StatefulWidget {
|
class DrawingPageTopActions extends StatefulWidget {
|
||||||
const DrawingPageTopActions(
|
const DrawingPageTopActions(
|
||||||
{Key? key, required this.controller, required this.noteName})
|
{Key? key, required this.controller, required this.noteMetaData})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
final PaintController controller;
|
final PaintController controller;
|
||||||
final String noteName;
|
final NoteMetaData noteMetaData;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<DrawingPageTopActions> createState() => _DrawingPageTopActionsState();
|
State<DrawingPageTopActions> createState() => _DrawingPageTopActionsState();
|
||||||
@ -81,8 +82,8 @@ class _DrawingPageTopActionsState extends State<DrawingPageTopActions> {
|
|||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
// todo move in correct submenu
|
// todo move in correct submenu
|
||||||
await exportPDF(
|
await exportPDF(widget.controller.strokes,
|
||||||
widget.controller.strokes, '${widget.noteName}.pdf');
|
'${widget.noteMetaData.name}.pdf');
|
||||||
|
|
||||||
Widget toast = Container(
|
Widget toast = Container(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../canvas/document_types.dart';
|
||||||
import '../canvas/drawing_page.dart';
|
import '../canvas/drawing_page.dart';
|
||||||
import '../context/file_change_notifier.dart';
|
import '../context/file_change_notifier.dart';
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ class NoteTile extends StatelessWidget {
|
|||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) =>
|
||||||
DrawingPage(filePath: data.relativePath, name: data.name),
|
DrawingPage(meta: NoteMetaData(data.relativePath, data.name)),
|
||||||
),
|
),
|
||||||
).then((value) =>
|
).then((value) =>
|
||||||
Provider.of<FileChangeNotifier>(context, listen: false)
|
Provider.of<FileChangeNotifier>(context, listen: false)
|
||||||
|
Loading…
Reference in New Issue
Block a user