-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PAINTROID-440, PAINTROID-441, PAINTROID-442 Created the landing page …
…and implemented the basic functionality (#8) PAINTROID-440, PAINTROID-441, PAINTROID-442 Created the landing page and implemented the basic functionality
- Loading branch information
1 parent
5c648d5
commit 5739d86
Showing
28 changed files
with
1,515 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:floor/floor.dart'; | ||
|
||
@entity | ||
class Project { | ||
String name; | ||
String path; | ||
DateTime lastModified; | ||
DateTime creationDate; | ||
String? resolution; | ||
String? format; | ||
int? size; | ||
String? imagePreviewPath; | ||
@PrimaryKey(autoGenerate: true) | ||
final int? id; | ||
|
||
Project({ | ||
required this.name, | ||
required this.path, | ||
required this.lastModified, | ||
required this.creationDate, | ||
this.resolution, | ||
this.format, | ||
this.size, | ||
this.imagePreviewPath, | ||
this.id, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:floor/floor.dart'; | ||
|
||
import 'model/project.dart'; | ||
|
||
@dao | ||
abstract class ProjectDAO { | ||
@Insert(onConflict: OnConflictStrategy.replace) | ||
Future<int> insertProject(Project project); | ||
|
||
@Insert(onConflict: OnConflictStrategy.replace) | ||
Future<List<int>> insertProjects(List<Project> projects); | ||
|
||
@Query('DELETE FROM Project WHERE id = :id') | ||
Future<void> deleteProject(int id); | ||
|
||
@delete | ||
Future<void> deleteProjects(List<Project> projects); | ||
|
||
@Query('SELECT * FROM Project order by lastModified desc') | ||
Future<List<Project>> getProjects(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:floor/floor.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:paintroid/data/model/project.dart'; | ||
import 'package:paintroid/data/project_dao.dart'; | ||
import 'package:paintroid/data/typeconverters/date_time_converter.dart'; | ||
import 'package:sqflite/sqflite.dart' as sqflite; | ||
|
||
part 'project_database.g.dart'; | ||
|
||
@TypeConverters([DateTimeConverter]) | ||
@Database(version: 1, entities: [Project]) | ||
abstract class ProjectDatabase extends FloorDatabase { | ||
ProjectDAO get projectDAO; | ||
|
||
static final provider = FutureProvider((ref) => | ||
$FloorProjectDatabase.databaseBuilder("project_database.db").build()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:floor/floor.dart'; | ||
|
||
class DateTimeConverter extends TypeConverter<DateTime, int> { | ||
@override | ||
DateTime decode(int databaseValue) { | ||
return DateTime.fromMillisecondsSinceEpoch(databaseValue); | ||
} | ||
|
||
@override | ||
int encode(DateTime value) { | ||
return value.millisecondsSinceEpoch; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
/// Returns [true] if user chose to delete the project or [null] if user | ||
/// dismiss the dialog by tapping outside | ||
Future<bool?> showDeleteDialog(BuildContext context, String name) => | ||
showGeneralDialog<bool>( | ||
context: context, | ||
pageBuilder: (_, __, ___) => DeleteProjectDialog(name: name), | ||
barrierDismissible: true, | ||
barrierLabel: "Show delete project dialog box"); | ||
|
||
class DeleteProjectDialog extends StatefulWidget { | ||
final String name; | ||
|
||
const DeleteProjectDialog({Key? key, required this.name}) : super(key: key); | ||
|
||
@override | ||
State<DeleteProjectDialog> createState() => _DeleteProjectDialogState(); | ||
} | ||
|
||
class _DeleteProjectDialogState extends State<DeleteProjectDialog> { | ||
@override | ||
Widget build(BuildContext context) => AlertDialog( | ||
title: Text("Delete ${widget.name}"), | ||
actions: const [ | ||
DialogElevatedButton(text: 'Cancel'), | ||
DialogTextButton(text: 'Delete'), | ||
], | ||
content: const Text("Do you really want to delete your project?"), | ||
); | ||
} | ||
|
||
class DialogTextButton extends StatelessWidget { | ||
final String text; | ||
|
||
const DialogTextButton({Key? key, required this.text}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) => TextButton( | ||
style: | ||
ButtonStyle(foregroundColor: MaterialStateProperty.all(Colors.red)), | ||
onPressed: () => Navigator.of(context).pop(true), | ||
child: Text(text), | ||
); | ||
} | ||
|
||
class DialogElevatedButton extends StatelessWidget { | ||
final String text; | ||
|
||
const DialogElevatedButton({Key? key, required this.text}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) => ElevatedButton( | ||
onPressed: () => Navigator.of(context).pop(false), | ||
child: Text(text, style: const TextStyle(color: Colors.white)), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.