display filename on top bar

rearrange some imports
add linter rules
This commit is contained in:
lukas-heiligenbrunner 2022-10-30 21:57:13 +01:00
parent ab1bacea00
commit 84eef41996
11 changed files with 78 additions and 52 deletions

View File

@ -22,8 +22,17 @@ linter:
# `// ignore_for_file: name_of_lint` syntax on the line or in the file # `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint. # producing the lint.
rules: rules:
avoid_print: false # Uncomment to disable the `avoid_print` rule avoid_print: true # Uncomment to disable the `avoid_print` rule
prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
prefer_relative_imports: true
avoid_empty_else: true
avoid_returning_null_for_future: true
avoid_web_libraries_in_flutter: true
collection_methods_unrelated_type: true
comment_references: true
control_flow_in_finally: true
empty_statements: true
unnecessary_null_checks: true
# Additional information about this file can be found at # Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options # https://dart.dev/guides/language/analysis-options

View File

@ -1,8 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:notes/context/file_change_notifier.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'canvas/drawing_page.dart'; import 'canvas/drawing_page.dart';
import 'context/file_change_notifier.dart';
import 'pages/all_notes_page.dart'; import 'pages/all_notes_page.dart';
import 'widgets/collapse_drawer.dart'; import 'widgets/collapse_drawer.dart';
@ -51,13 +51,17 @@ class _AppState extends State<App> {
return FloatingActionButton( return FloatingActionButton(
onPressed: () async { onPressed: () async {
final now = DateTime.now(); final now = DateTime.now();
String filename = final name =
'note-${now.year}_${now.month}_${now.day}-${now.hour}_${now.minute}.dbnote'; 'note-${now.year}_${now.month}_${now.day}-${now.hour}_${now.minute}';
final filename = '$name.dbnote';
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (ctx) => DrawingPage(filePath: filename), builder: (ctx) => DrawingPage(
filePath: filename,
name: name,
),
), ),
).then((value) => ).then((value) =>
Provider.of<FileChangeNotifier>(context, listen: false) Provider.of<FileChangeNotifier>(context, listen: false)

View File

@ -35,6 +35,7 @@ class Stroke {
} }
Stroke.fromPoints(this.points, this.id, this.color); Stroke.fromPoints(this.points, this.id, this.color);
Stroke(this.id, this.color); Stroke(this.id, this.color);
} }

View File

@ -1,22 +1,25 @@
import 'dart:math'; import 'dart:math';
import 'dart:ui'; import 'dart:ui';
import 'package:fluentui_system_icons/fluentui_system_icons.dart'; import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:notes/savesystem/note_file.dart';
import '../savesystem/note_file.dart';
import '../widgets/icon_material_button.dart';
import '../widgets/tool_bar.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';
import '../widgets/icon_material_button.dart';
import '../widgets/tool_bar.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 String filePath;
final String name;
const DrawingPage({Key? key, required this.filePath}) : super(key: key); const DrawingPage({Key? key, required this.filePath, required this.name})
: super(key: key);
@override @override
State<DrawingPage> createState() => _DrawingPageState(); State<DrawingPage> createState() => _DrawingPageState();
@ -53,37 +56,40 @@ class _DrawingPageState extends State<DrawingPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(backgroundColor: Colors.blueGrey, actions: [ appBar: AppBar(
IconMaterialButton( backgroundColor: Colors.blueGrey,
icon: const Icon(FluentIcons.book_open_48_filled), title: Text(widget.name),
color: const Color.fromRGBO(255, 255, 255, .85), actions: [
onPressed: () { IconMaterialButton(
// todo implement icon: const Icon(FluentIcons.book_open_48_filled),
}, color: const Color.fromRGBO(255, 255, 255, .85),
), onPressed: () {
IconMaterialButton( // todo implement
icon: const Icon(FluentIcons.document_one_page_24_regular), },
color: const Color.fromRGBO(255, 255, 255, .85), ),
onPressed: () { IconMaterialButton(
// todo implement icon: const Icon(FluentIcons.document_one_page_24_regular),
}, color: const Color.fromRGBO(255, 255, 255, .85),
), onPressed: () {
IconMaterialButton( // todo implement
icon: const Icon(Icons.attachment_outlined), },
color: const Color.fromRGBO(255, 255, 255, .85), ),
onPressed: () { IconMaterialButton(
// todo implement icon: const Icon(Icons.attachment_outlined),
}, color: const Color.fromRGBO(255, 255, 255, .85),
rotation: -pi / 4, onPressed: () {
), // todo implement
IconMaterialButton( },
icon: const Icon(Icons.more_vert), rotation: -pi / 4,
color: const Color.fromRGBO(255, 255, 255, .85), ),
onPressed: () { IconMaterialButton(
// todo implement icon: const Icon(Icons.more_vert),
}, color: const Color.fromRGBO(255, 255, 255, .85),
), onPressed: () {
]), // todo implement
},
),
]),
body: Row( body: Row(
children: [ children: [
ToolBar( ToolBar(
@ -110,7 +116,7 @@ class _DrawingPageState extends State<DrawingPage> {
setState(() { setState(() {
offset = Offset((-canvasWidth * zoom) + canvasWidth, newOffset.dy); offset = Offset((-canvasWidth * zoom) + canvasWidth, newOffset.dy);
}); });
print(offset); debugPrint(offset.toString());
} else { } else {
setState(() { setState(() {
offset = offset + delta; offset = offset + delta;

View File

@ -1,8 +1,9 @@
import 'dart:math'; import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:notes/canvas/paint_controller.dart';
import 'package:notes/canvas/screen_document_mapping.dart'; import 'paint_controller.dart';
import 'screen_document_mapping.dart';
final Rect a4Page = final Rect a4Page =
Rect.fromPoints(const Offset(.0, .0), const Offset(210, 210 * sqrt2)); Rect.fromPoints(const Offset(.0, .0), const Offset(210, 210 * sqrt2));

View File

@ -1,5 +1,6 @@
import 'dart:math'; import 'dart:math';
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';

View File

@ -1,9 +1,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:notes/context/file_change_notifier.dart';
import 'package:notes/widgets/icon_material_button.dart';
import 'package:notes/widgets/note_tile.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../context/file_change_notifier.dart';
import '../widgets/icon_material_button.dart';
import '../widgets/note_tile.dart';
class AllNotesPage extends StatefulWidget { class AllNotesPage extends StatefulWidget {
const AllNotesPage({Key? key}) : super(key: key); const AllNotesPage({Key? key}) : super(key: key);

View File

@ -1,7 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'note_file.dart';
import '../canvas/document_types.dart'; import '../canvas/document_types.dart';
import 'note_file.dart';
extension LineLoading on NoteFile { extension LineLoading on NoteFile {
Future<List<Stroke>> loadStrokes() async { Future<List<Stroke>> loadStrokes() async {

View File

@ -1,8 +1,9 @@
import 'dart:io'; import 'dart:io';
import 'package:notes/savesystem/path.dart';
import 'package:sqflite/sqflite.dart'; import 'package:sqflite/sqflite.dart';
import 'path.dart';
class NoteFile { class NoteFile {
late Database _db; late Database _db;
String filepath; String filepath;

View File

@ -1,9 +1,10 @@
import 'package:fluentui_system_icons/fluentui_system_icons.dart'; import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:notes/context/file_change_notifier.dart';
import 'package:notes/widgets/drawer_item.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../context/file_change_notifier.dart';
import 'drawer_item.dart';
enum View { all, shared, recycle, folders } enum View { all, shared, recycle, folders }
class CollapseDrawer extends StatefulWidget { class CollapseDrawer extends StatefulWidget {

View File

@ -24,7 +24,8 @@ class NoteTile extends StatelessWidget {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => DrawingPage(filePath: data.relativePath), builder: (context) =>
DrawingPage(filePath: data.relativePath, name: data.name),
), ),
).then((value) => ).then((value) =>
Provider.of<FileChangeNotifier>(context, listen: false) Provider.of<FileChangeNotifier>(context, listen: false)