made task creation flow
This commit is contained in:
@@ -667,6 +667,8 @@ class GradesPageState extends State<GradesPage> {
|
||||
|
||||
// SoonAlert.show(context: context);
|
||||
gradeCalcTotal(context);
|
||||
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
@@ -35,6 +35,7 @@ import 'package:refilc_plus/models/premium_scopes.dart';
|
||||
import 'package:refilc_plus/providers/plus_provider.dart';
|
||||
import 'package:refilc_plus/ui/mobile/plus/premium_inline.dart';
|
||||
import 'package:refilc_plus/ui/mobile/plus/upsell.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'notes_page.i18n.dart';
|
||||
|
||||
enum AbsenceFilter { absences, delays, misses }
|
||||
@@ -65,9 +66,14 @@ class NotesPageState extends State<NotesPage> with TickerProviderStateMixin {
|
||||
|
||||
Map<String, bool> doneItems = {};
|
||||
List<Widget> noteTiles = [];
|
||||
List<TodoItem> todoItems = [];
|
||||
|
||||
final TextEditingController _taskName = TextEditingController();
|
||||
final TextEditingController _taskContent = TextEditingController();
|
||||
|
||||
void generateTiles() async {
|
||||
doneItems = await databaseProvider.userQuery.toDoItems(userId: user.id!);
|
||||
todoItems = await databaseProvider.userQuery.getTodoItems(userId: user.id!);
|
||||
|
||||
List<Widget> tiles = [];
|
||||
|
||||
@@ -82,7 +88,7 @@ class NotesPageState extends State<NotesPage> with TickerProviderStateMixin {
|
||||
List<Widget> toDoTiles = [];
|
||||
|
||||
if (hw.isNotEmpty &&
|
||||
!Provider.of<PlusProvider>(context, listen: false)
|
||||
Provider.of<PlusProvider>(context, listen: false)
|
||||
.hasScope(PremiumScopes.unlimitedSelfNotes)) {
|
||||
toDoTiles.addAll(hw.map((e) => TickTile(
|
||||
padding: EdgeInsets.zero,
|
||||
@@ -102,6 +108,21 @@ class NotesPageState extends State<NotesPage> with TickerProviderStateMixin {
|
||||
)));
|
||||
}
|
||||
|
||||
if (selfNoteProvider.todos.isNotEmpty) {
|
||||
toDoTiles.addAll(selfNoteProvider.todos.map((e) => TickTile(
|
||||
padding: EdgeInsets.zero,
|
||||
title: e.title,
|
||||
description: e.content,
|
||||
isTicked: e.done,
|
||||
onTap: (p0) async {
|
||||
todoItems.firstWhere((element) => element.id == e.id).done = p0;
|
||||
|
||||
await databaseProvider.userStore
|
||||
.storeSelfTodoItems(todoItems, userId: user.id!);
|
||||
},
|
||||
)));
|
||||
}
|
||||
|
||||
if (toDoTiles.isNotEmpty) {
|
||||
tiles.add(const SizedBox(
|
||||
height: 10.0,
|
||||
@@ -313,6 +334,8 @@ class NotesPageState extends State<NotesPage> with TickerProviderStateMixin {
|
||||
.fetch(
|
||||
from: DateTime.now().subtract(const Duration(days: 30)));
|
||||
Provider.of<SelfNoteProvider>(context, listen: false).restore();
|
||||
Provider.of<SelfNoteProvider>(context, listen: false)
|
||||
.restoreTodo();
|
||||
|
||||
generateTiles();
|
||||
|
||||
@@ -410,7 +433,159 @@ class NotesPageState extends State<NotesPage> with TickerProviderStateMixin {
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
color: Theme.of(context).colorScheme.background),
|
||||
child: ListTile(
|
||||
title: Row(
|
||||
children: [
|
||||
const Icon(Icons.task_outlined),
|
||||
const SizedBox(
|
||||
width: 10.0,
|
||||
),
|
||||
Text('new_task'.i18n),
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
if (!Provider.of<PlusProvider>(context, listen: false)
|
||||
.hasScope(PremiumScopes.unlimitedSelfNotes)) {
|
||||
PlusLockedFeaturePopup.show(
|
||||
context: context, feature: PremiumFeature.selfNotes);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
showTaskCreation(context);
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
void showTaskCreation(context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(14.0))),
|
||||
contentPadding: const EdgeInsets.only(top: 10.0),
|
||||
title: Text("new_task".i18n),
|
||||
content: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 10.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextField(
|
||||
controller: _taskName,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(
|
||||
borderSide:
|
||||
const BorderSide(color: Colors.grey, width: 1.5),
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide:
|
||||
const BorderSide(color: Colors.grey, width: 1.5),
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||
hintText: "task_name".i18n,
|
||||
suffixIcon: IconButton(
|
||||
icon: const Icon(
|
||||
FeatherIcons.x,
|
||||
color: Colors.grey,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_taskName.text = "";
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
TextField(
|
||||
controller: _taskContent,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(
|
||||
borderSide:
|
||||
const BorderSide(color: Colors.grey, width: 1.5),
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide:
|
||||
const BorderSide(color: Colors.grey, width: 1.5),
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||
hintText: "task_content".i18n,
|
||||
suffixIcon: IconButton(
|
||||
icon: const Icon(
|
||||
FeatherIcons.x,
|
||||
color: Colors.grey,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_taskContent.text = "";
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
"cancel".i18n,
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).maybePop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text(
|
||||
"next".i18n,
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
),
|
||||
onPressed: () async {
|
||||
todoItems.add(TodoItem.fromJson({
|
||||
'id': const Uuid().v4(),
|
||||
'title': _taskName.text.replaceAll(' ', '') != ""
|
||||
? _taskName.text
|
||||
: 'no_title'.i18n,
|
||||
'content': _taskContent.text,
|
||||
'done': false,
|
||||
}));
|
||||
|
||||
await databaseProvider.userStore
|
||||
.storeSelfTodoItems(todoItems, userId: user.id!);
|
||||
|
||||
setState(() {
|
||||
_taskName.text = "";
|
||||
_taskContent.text = "";
|
||||
});
|
||||
|
||||
Provider.of<SelfNoteProvider>(context, listen: false).restore();
|
||||
Provider.of<SelfNoteProvider>(context, listen: false)
|
||||
.restoreTodo();
|
||||
|
||||
generateTiles();
|
||||
|
||||
Navigator.of(context).pop(true);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@ extension ScreensLocalization on String {
|
||||
"hint_t": "Note title...",
|
||||
"your_notes": "Your Notes",
|
||||
"new_image": "New Image",
|
||||
"no_title": "No title",
|
||||
"task_content": "Task content...",
|
||||
"task_name": "Task title...",
|
||||
"new_task": "New Task",
|
||||
},
|
||||
"hu_hu": {
|
||||
"notes": "Füzet",
|
||||
@@ -26,6 +30,10 @@ extension ScreensLocalization on String {
|
||||
"hint_t": "Jegyzet címe...",
|
||||
"your_notes": "Jegyzeteid",
|
||||
"new_image": "Új kép",
|
||||
"no_title": "Nincs cím",
|
||||
"task_content": "Feladat tartalma...",
|
||||
"task_name": "Feladat címe...",
|
||||
"new_task": "Új feladat",
|
||||
},
|
||||
"de_de": {
|
||||
"notes": "Broschüre",
|
||||
@@ -38,6 +46,10 @@ extension ScreensLocalization on String {
|
||||
"hint_t": "Titel notieren...",
|
||||
"your_notes": "Deine Noten",
|
||||
"new_image": "Neues Bild",
|
||||
"no_title": "Kein Titel",
|
||||
"task_content": "Aufgabeninhalt...",
|
||||
"task_name": "Aufgabentitel...",
|
||||
"new_task": "Neue Aufgabe",
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -143,6 +143,7 @@ class _ImageNoteEditorState extends State<ImageNoteEditor> {
|
||||
.storeSelfNotes(selfNotes, userId: widget.u.id);
|
||||
|
||||
Provider.of<SelfNoteProvider>(context, listen: false).restore();
|
||||
Provider.of<SelfNoteProvider>(context, listen: false).restoreTodo();
|
||||
|
||||
debugPrint('$file');
|
||||
}
|
||||
|
||||
@@ -268,6 +268,7 @@ class NotesScreenState extends State<NotesScreen> {
|
||||
Provider.of<HomeworkProvider>(context, listen: false)
|
||||
.fetch(from: DateTime.now().subtract(const Duration(days: 30)));
|
||||
Provider.of<SelfNoteProvider>(context, listen: false).restore();
|
||||
Provider.of<SelfNoteProvider>(context, listen: false).restoreTodo();
|
||||
|
||||
return Future(() => null);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user