Polished
This commit is contained in:
@@ -3,9 +3,7 @@ import 'main.dart';
|
||||
import 'NewTask.dart';
|
||||
import 'Data.dart';
|
||||
import 'User.dart' as User;
|
||||
import 'package:sn_progress_dialog/sn_progress_dialog.dart';
|
||||
|
||||
late ProgressDialog progressDialog;
|
||||
class Tasks extends StatefulWidget {
|
||||
const Tasks({Key? key}) : super(key: key);
|
||||
|
||||
@@ -17,10 +15,29 @@ class _TasksState extends State<Tasks> {
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
progressDialog = ProgressDialog(context: context);
|
||||
User.progressDialog=progressDialog;
|
||||
UpdateList();
|
||||
// init(context);
|
||||
}
|
||||
|
||||
var refreshSub;
|
||||
void init(BuildContext context) async{
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
refreshSub = User.refreshStream.stream.listen((value) {
|
||||
print("Streaming refresh : $value");
|
||||
if(value){
|
||||
// dialogs.waiting(context, "Syncing");
|
||||
print("Opening progress dialog");
|
||||
}else{
|
||||
// dialogs.hide(context);
|
||||
print("Closing progress dialog");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override void dispose() {
|
||||
// TODO: implement dispose
|
||||
super.dispose();
|
||||
refreshSub?.cancel();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -67,12 +84,12 @@ class _TasksState extends State<Tasks> {
|
||||
|
||||
void UpdateList() async {
|
||||
|
||||
try{progressDialog.show(max:100, msg: 'Loading Task Types...');}catch(e){}
|
||||
await User.updateTasksList();
|
||||
// try{progressDialog.show(max:100, msg: 'Loading Task Types...');}catch(e){}
|
||||
await User.refreshUserData();
|
||||
// hideProgressDialog();
|
||||
setState(() {});
|
||||
if(mounted)setState(() {});
|
||||
|
||||
try{progressDialog.update(value: 100);}catch(e){}
|
||||
// try{progressDialog.update(value: 100);}catch(e){}
|
||||
}
|
||||
|
||||
List<Widget> PrintTasks() {
|
||||
@@ -171,7 +188,6 @@ class _TasksState extends State<Tasks> {
|
||||
}
|
||||
|
||||
void DeleteSelectedTasks() async{
|
||||
progressDialog.show(max: 100, msg: "Deleting ${selectedTasks.length} ");
|
||||
selectedTasks.forEach((element) async {
|
||||
await User.UserOperations.deleteTask(element, bulk:true);
|
||||
});
|
||||
@@ -181,7 +197,6 @@ class _TasksState extends State<Tasks> {
|
||||
selectedTasks=[];
|
||||
selecting=false;
|
||||
setState(() {
|
||||
progressDialog.update(value: 100);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user