Skip to content

Commit

Permalink
fix: constant provider refresh due to change of theme handling caused…
Browse files Browse the repository at this point in the history
… unstable project tab.
  • Loading branch information
kolaente authored and Benimautner committed Sep 26, 2024
1 parent 7a91442 commit fe0bfea
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 54 deletions.
7 changes: 2 additions & 5 deletions lib/components/SentryModal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ import 'package:flutter/material.dart';
import 'package:vikunja_app/global.dart';
import 'package:vikunja_app/main.dart';

Future<void> showSentryModal(BuildContext context) {
return VikunjaGlobal.of(context)
.settingsManager
.getSentryModalShown()
.then((sentryModalShown) {
void showSentryModal(BuildContext context, VikunjaGlobalState global) {
global.settingsManager.getSentryModalShown().then((sentryModalShown) {
VikunjaGlobal.of(context).settingsManager.setSentryModalShown(true);
if (!sentryModalShown) {
return showDialog<void>(
Expand Down
26 changes: 15 additions & 11 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:vikunja_app/api/task_implementation.dart';
import 'package:vikunja_app/api/client.dart';
import 'package:vikunja_app/service/services.dart';
import 'package:vikunja_app/stores/project_store.dart';
import 'package:workmanager/workmanager.dart';
import 'package:vikunja_app/global.dart';
import 'package:vikunja_app/pages/home.dart';
Expand Down Expand Up @@ -114,17 +116,19 @@ void main() async {
} catch (e) {
print("Failed to initialize workmanager: $e");
}
runApp(VikunjaGlobal(
child: new VikunjaApp(
home: HomePage(),
key: UniqueKey(),
navkey: globalNavigatorKey,
),
login: new VikunjaApp(
home: LoginPage(),
key: UniqueKey(),
),
));
runApp(ChangeNotifierProvider<ProjectProvider>(
create: (_) => new ProjectProvider(),
child: VikunjaGlobal(
child: new VikunjaApp(
home: HomePage(),
key: UniqueKey(),
navkey: globalNavigatorKey,
),
login: new VikunjaApp(
home: LoginPage(),
key: UniqueKey(),
),
)));
}

class ThemeModel with ChangeNotifier {
Expand Down
4 changes: 1 addition & 3 deletions lib/pages/landing_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ class LandingPageState extends State<LandingPage> {
children: [ListView(), Center(child: Text("This view is empty"))]);
break;
case PageStatus.success:
Future.delayed(Duration(seconds: 2), () {
showSentryModal(context);
});
showSentryModal(context, VikunjaGlobal.of(context));
body = ListView(
scrollDirection: Axis.vertical,
padding: EdgeInsets.symmetric(vertical: 8.0),
Expand Down
7 changes: 4 additions & 3 deletions lib/pages/project/overview.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:after_layout/after_layout.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:vikunja_app/pages/project/project_task_list.dart';

import '../../components/AddDialog.dart';
import '../../components/ErrorDialog.dart';
import '../../global.dart';
import '../../models/project.dart';
import '../../stores/project_store.dart';

class ProjectOverviewPage extends StatefulWidget {
@override
Expand Down Expand Up @@ -52,9 +54,8 @@ class _ProjectOverviewPageState extends State<ProjectOverviewPage>
return Column(children: [
ListTile(
onTap: () {
setState(() {
openList(context, project);
});
Provider.of<ProjectProvider>(context, listen: false);
openList(context, project);
},
contentPadding: insets,
leading: IconButton(
Expand Down
39 changes: 13 additions & 26 deletions lib/pages/project/project_task_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class BucketProps {
class ListPage extends StatefulWidget {
final Project project;

//ListPage({this.taskList}) : super(key: Key(taskList.id.toString()));
ListPage({required this.project})
: super(key: Key(Random().nextInt(100000).toString()));
ListPage({required this.project}) : super(key: Key(project.id.toString()));
//ListPage({required this.project})
// : super(key: Key(Random().nextInt(100000).toString()));

@override
_ListPageState createState() => _ListPageState();
Expand Down Expand Up @@ -64,7 +64,8 @@ class _ListPageState extends State<ListPage> {

@override
Widget build(BuildContext context) {
taskState = Provider.of<ProjectProvider>(context);
//return Text("test");
taskState = Provider.of<ProjectProvider>(context, listen: false);
_kanban = KanbanClass(context, nullSetState, _onViewTapped, _addItemDialog,
_project, _project.views[_viewIndex]);

Expand Down Expand Up @@ -169,19 +170,6 @@ class _ListPageState extends State<ListPage> {
tooltip: view.title,
))
.toList(),
/*
;const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.view_list),
label: 'List',
tooltip: 'List',
),
BottomNavigationBarItem(
icon: Icon(Icons.view_kanban),
label: 'Kanban',
tooltip: 'Kanban',
),
], */
currentIndex: _viewIndex,
onTap: _onViewTapped,
)
Expand Down Expand Up @@ -388,13 +376,12 @@ class _ListPageState extends State<ListPage> {
}

openList(BuildContext context, Project project) {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => ChangeNotifierProvider<ProjectProvider>(
create: (_) => new ProjectProvider(),
child: ListPage(
project: project,
),
),
// ListPage(taskList: list)
));
Provider.of<ProjectProvider>(context, listen: false);
Navigator.push(context, MaterialPageRoute(builder: (context) {
Provider.of<ProjectProvider>(context, listen: false);
return ListPage(
project: project,
);
}));
// ListPage(taskList: list)
}
5 changes: 1 addition & 4 deletions lib/pages/user/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,14 @@ class _LoginPageState extends State<LoginPage> {
print(value);
if (value != null) setState(() => pastServers = value);
});
showSentryModal(context, VikunjaGlobal.of(context));
});
}

@override
Widget build(BuildContext ctx) {
Client client = VikunjaGlobal.of(context).client;

Future.delayed(Duration(seconds: 2), () {
showSentryModal(context);
});

return Scaffold(
body: Center(
child: SingleChildScrollView(
Expand Down
2 changes: 0 additions & 2 deletions lib/stores/project_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class ProjectProvider with ChangeNotifier {
int page = 1}) {
_buckets = [];
pageStatus = PageStatus.loading;
notifyListeners();

Map<String, List<String>> queryParams = {
"page": [page.toString()]
Expand Down Expand Up @@ -143,7 +142,6 @@ class ProjectProvider with ChangeNotifier {
required int listId}) {
var globalState = VikunjaGlobal.of(context);
if (newTask.bucketId == null) pageStatus = PageStatus.loading;
notifyListeners();

return globalState.taskService.add(listId, newTask).then((task) {
if (task == null) {
Expand Down

0 comments on commit fe0bfea

Please sign in to comment.