Skip to content

Commit 56b8275

Browse files
authored
Merge pull request #325 from JangamRuthvik/dev
tap-to-open task details page upon tapping on task of listview on home widget
2 parents 49d4e92 + 5a871a6 commit 56b8275

File tree

5 files changed

+68
-60
lines changed

5 files changed

+68
-60
lines changed

android/app/src/main/kotlin/com/example/taskwarrior/TaskWarriorWidgetProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class TaskWarriorWidgetProvider : AppWidgetProvider() {
3838
flags = Intent. FLAG_ACTIVITY_NEW_TASK
3939
context?.startActivity(this)
4040
}
41-
HomeWidgetLaunchIntent.getActivity(context, MainActivity::class.java, Uri.parse("TaskWarrior://taskView?taskId=$uuid"))
41+
// HomeWidgetLaunchIntent.getActivity(context, MainActivity::class.java, Uri.parse("TaskWarrior://taskView?taskId=$uuid"))
4242
}
4343
}
4444
super.onReceive(context, intent)

android/app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<string name="text_data_key">textData</string>
77
<string name="image_data_key">imageData</string>
88
<string name="app_widget_launch_action">es.antonborri.home_widget.action.LAUNCH</string>
9-
<string name="app_widget_card_clicked_uri">TaskWarriorAppWidget://cardClicked</string>
9+
<string name="app_widget_card_clicked_uri">taskwarriorappwidget://cardclicked</string>
1010
<string name="my_widget_description">This widget shows pending tasks from TaskWarrior app</string>
1111
<string name="appwidget_text">TaskWarrior</string>
1212
<string name="add_widget">Add widget</string>

lib/main.dart

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ import 'package:path_provider/path_provider.dart';
1212
import 'package:permission_handler/permission_handler.dart';
1313
import 'package:shared_preferences/shared_preferences.dart';
1414
import 'package:sizer/sizer.dart';
15+
import 'package:taskwarrior/config/app_settings.dart';
1516
import 'package:taskwarrior/controller/WidgetController.dart';
1617
import 'package:taskwarrior/controller/onboarding_controller.dart';
1718
import 'package:taskwarrior/routes/pageroute.dart';
19+
import 'package:taskwarrior/services/task_details.dart';
1820
import 'package:taskwarrior/views/Onboarding/onboarding_screen.dart';
1921
import 'package:taskwarrior/views/profile/profile.dart';
2022
import 'package:taskwarrior/widgets/app_placeholder.dart';
@@ -64,20 +66,7 @@ Future main([List<String> args = const []]) async {
6466
return const AppSetupPlaceholder();
6567
}
6668
})));
67-
HomeWidget.widgetClicked.listen((uri) async{
68-
if (uri != null) {
69-
debugPrint("i am here and uri is $uri");
70-
String? uuid = uri.queryParameters["uuid"];
71-
debugPrint('uuid is $uuid');
72-
if (uuid!=null) {
73-
// Future.delayed(Duration(seconds: 5)).then((value) => Navigator.push(context, MaterialPageRoute(builder: (context) => DetailRoute(uuid),)));
74-
}
75-
}
76-
if (uri?.host == "cardClicked") {
77-
final taskUUID = uri!.queryParameters["uuid"];
78-
debugPrint(taskUUID);
79-
}
80-
});
69+
8170
}
8271

8372
Future<List<Directory>> getDirectories() async {
@@ -113,13 +102,33 @@ class _MyAppState extends State<MyApp> {
113102
Directory? baseDirectory;
114103
List<Task> allData = [];
115104
bool stopTraver = false;
105+
106+
bool isHomeWidgetTaskTapped = false;
107+
late String uuid;
116108
@override
117109
void initState() {
118110
super.initState();
119111

120112
///sort the data by daily burn down
121113
122114
notificationService.initiliazeNotification();
115+
helperFunction();
116+
}
117+
118+
void helperFunction() async {
119+
Uri? myUri = await HomeWidget.initiallyLaunchedFromHomeWidget();
120+
if (myUri != null) {
121+
if (myUri.host == "cardclicked") {
122+
if (myUri.queryParameters["uuid"] != null) {
123+
uuid = myUri.queryParameters["uuid"] as String;
124+
setState(() {
125+
isHomeWidgetTaskTapped = true;
126+
});
127+
// print('is tapped is $isHomeWidgetTaskTapped');
128+
}
129+
// debugPrint('uuid is $uuid');
130+
}
131+
}
123132
}
124133

125134
@override
@@ -154,7 +163,17 @@ class _MyAppState extends State<MyApp> {
154163
PageRoutes.profile: (context) => const ProfilePage(),
155164
},
156165

157-
home: CheckOnboardingStatus(),
166+
home: isHomeWidgetTaskTapped == false
167+
? CheckOnboardingStatus()
168+
: FutureBuilder(future: Future.delayed(const Duration(seconds: 2)), builder: (context, snapshot) {
169+
if (snapshot.connectionState == ConnectionState.waiting) {
170+
return Scaffold(
171+
backgroundColor:
172+
AppSettings.isDarkMode ? Palette.kToDark.shade200 : Colors.white,
173+
body: const Center(child: CircularProgressIndicator()));
174+
}
175+
return DetailRoute(uuid);
176+
},),
158177
);
159178
}));
160179
}

lib/views/home/home.dart

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
44

55
import 'package:double_back_to_close_app/double_back_to_close_app.dart';
66
import 'package:google_fonts/google_fonts.dart';
7+
import 'package:home_widget/home_widget.dart';
78
import 'package:shared_preferences/shared_preferences.dart';
89

910
import 'package:taskwarrior/config/app_settings.dart';
@@ -12,6 +13,7 @@ import 'package:taskwarrior/controller/home_tour_controller.dart';
1213
import 'package:taskwarrior/drawer/filter_drawer.dart';
1314
import 'package:taskwarrior/drawer/nav_drawer.dart';
1415
import 'package:taskwarrior/model/storage/storage_widget.dart';
16+
import 'package:taskwarrior/services/task_details.dart';
1517
import 'package:taskwarrior/taskserver/ntaskserver.dart';
1618
import 'package:taskwarrior/views/home/home_tour.dart';
1719
import 'package:taskwarrior/widgets/add_Task.dart';
@@ -147,9 +149,28 @@ class _HomePageState extends State<HomePage> {
147149
}
148150

149151
bool hideKey = true;
150-
152+
bool isHomeWidgetTaskTapped = false;
153+
late String uuid;
151154
@override
152155
Widget build(BuildContext context) {
156+
157+
HomeWidget.widgetClicked.listen((uri) async{
158+
// print('i am here and uri is $uri');
159+
// print('is tapped is i am being called');
160+
if (uri != null) {
161+
if (uri.host == "cardclicked") {
162+
if (uri.queryParameters["uuid"] != null) {
163+
uuid = uri.queryParameters["uuid"] as String;
164+
setState(() {
165+
isHomeWidgetTaskTapped = true;
166+
});
167+
// print('is tapped is $isHomeWidgetTaskTapped');
168+
}
169+
debugPrint('uuid is $uuid');
170+
}
171+
}
172+
173+
});
153174
Server? server;
154175
Credentials? credentials;
155176

@@ -201,7 +222,7 @@ class _HomePageState extends State<HomePage> {
201222
tagFilters: tagFilters,
202223
);
203224

204-
return Scaffold(
225+
return isHomeWidgetTaskTapped == false ? Scaffold(
205226
appBar: AppBar(
206227
backgroundColor: TaskWarriorColors.kprimaryBackgroundColor,
207228
surfaceTintColor: TaskWarriorColors.kprimaryBackgroundColor,
@@ -399,7 +420,7 @@ class _HomePageState extends State<HomePage> {
399420
}),
400421
),
401422
resizeToAvoidBottomInset: false,
402-
);
423+
) : DetailRoute(uuid);
403424
}
404425

405426
refresh() {

pubspec.lock

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -624,30 +624,6 @@ packages:
624624
url: "https://pub.dev"
625625
source: hosted
626626
version: "4.8.1"
627-
leak_tracker:
628-
dependency: transitive
629-
description:
630-
name: leak_tracker
631-
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
632-
url: "https://pub.dev"
633-
source: hosted
634-
version: "10.0.0"
635-
leak_tracker_flutter_testing:
636-
dependency: transitive
637-
description:
638-
name: leak_tracker_flutter_testing
639-
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
640-
url: "https://pub.dev"
641-
source: hosted
642-
version: "2.0.1"
643-
leak_tracker_testing:
644-
dependency: transitive
645-
description:
646-
name: leak_tracker_testing
647-
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
648-
url: "https://pub.dev"
649-
source: hosted
650-
version: "2.0.1"
651627
lints:
652628
dependency: transitive
653629
description:
@@ -676,26 +652,26 @@ packages:
676652
dependency: transitive
677653
description:
678654
name: matcher
679-
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
655+
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
680656
url: "https://pub.dev"
681657
source: hosted
682-
version: "0.12.16+1"
658+
version: "0.12.16"
683659
material_color_utilities:
684660
dependency: transitive
685661
description:
686662
name: material_color_utilities
687-
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
663+
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
688664
url: "https://pub.dev"
689665
source: hosted
690-
version: "0.8.0"
666+
version: "0.5.0"
691667
meta:
692668
dependency: transitive
693669
description:
694670
name: meta
695-
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
671+
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
696672
url: "https://pub.dev"
697673
source: hosted
698-
version: "1.11.0"
674+
version: "1.10.0"
699675
mime:
700676
dependency: transitive
701677
description:
@@ -740,10 +716,10 @@ packages:
740716
dependency: transitive
741717
description:
742718
name: path
743-
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
719+
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
744720
url: "https://pub.dev"
745721
source: hosted
746-
version: "1.9.0"
722+
version: "1.8.3"
747723
path_parsing:
748724
dependency: transitive
749725
description:
@@ -1266,14 +1242,6 @@ packages:
12661242
url: "https://pub.dev"
12671243
source: hosted
12681244
version: "2.1.4"
1269-
vm_service:
1270-
dependency: transitive
1271-
description:
1272-
name: vm_service
1273-
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
1274-
url: "https://pub.dev"
1275-
source: hosted
1276-
version: "13.0.0"
12771245
watcher:
12781246
dependency: transitive
12791247
description:

0 commit comments

Comments
 (0)