-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvement in refDetail and Space Object sharing enhancements #2472
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2472 +/- ##
==========================================
+ Coverage 27.76% 27.91% +0.15%
==========================================
Files 660 660
Lines 44697 44775 +78
==========================================
+ Hits 12410 12499 +89
+ Misses 32287 32276 -11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…into kumar/ref-details-improvements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added few comment for code explanation.
@@ -3,7 +3,7 @@ import 'dart:io'; | |||
import 'package:appcheck/appcheck.dart'; | |||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | |||
|
|||
enum ExternalApps { whatsApp, telegram, signal } | |||
enum ExternalApps { whatsApp, whatsBusiness, telegram, signal } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added WhatsBusiness app direct share option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just moved file to different folder.
required BuildContext context, | ||
required String text, | ||
}) async { | ||
if (Platform.isAndroid) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Direct share to Signal App only available for android platform with Explicit Intent.
For iOS users, given better guide about sharing to Signal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually do the path of only showing features if they are available - if this isn't possible on iOS rather than showing some error messages, the button should not show up.
typedef SpaceObjectDetails = ({ | ||
String spaceId, | ||
ObjectType objectType, | ||
String objectId, | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get rid of SpaceObjectDetails
and use RefDetails
param directly to sharing options.
Future<String> Function()? shareContentBuilder, | ||
Future<FileDetails> Function()? fileDetailContentBuilder, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExternalLink and FileSharing will be based on the callback function which make data accessing only when user interact will specific option.
NewsReferencesType? getNewsRefTypeFromObjType(ObjectType objectType) { | ||
return switch (objectType) { | ||
ObjectType.pin => NewsReferencesType.pin, | ||
ObjectType.calendarEvent => NewsReferencesType.calendarEvent, | ||
ObjectType.taskList => NewsReferencesType.taskList, | ||
_ => null, | ||
}; | ||
} | ||
|
||
Future<RefDetails?> getRefDetails({ | ||
required WidgetRef ref, | ||
required SpaceObjectDetails objectDetails, | ||
}) async { | ||
final objectId = objectDetails.objectId; | ||
switch (objectDetails.objectType) { | ||
case ObjectType.pin: | ||
final sourcePin = await ref.watch(pinProvider(objectId).future); | ||
return await sourcePin.refDetails(); | ||
case ObjectType.calendarEvent: | ||
final sourceEvent = | ||
await ref.watch(calendarEventProvider(objectId).future); | ||
return await sourceEvent.refDetails(); | ||
case ObjectType.taskList: | ||
final sourceTaskList = | ||
await ref.watch(taskListProvider(objectId).future); | ||
return await sourceTaskList.refDetails(); | ||
default: | ||
return null; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Say Good bye to unwanted code as refDetails
is now directly available from class param.
final GestureTapCallback? onTapCopy; | ||
final GestureTapCallback? onTapQr; | ||
final GestureTapCallback? onTapSignal; | ||
final GestureTapCallback? onTapWhatsApp; | ||
final GestureTapCallback? onTapTelegram; | ||
final GestureTapCallback? onTapMore; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get rid of this callbacks
as all of the options will be used when shareContent
is available.
final refDetails = await event.refDetails(); | ||
final internalLink = refDetails.generateInternalLink(true); | ||
if (context.mounted) { | ||
openShareSpaceObjectDialog( | ||
context: context, | ||
spaceObjectDetails: ( | ||
spaceId: event.roomIdStr(), | ||
objectType: ObjectType.calendarEvent, | ||
objectId: widget.calendarId, | ||
), | ||
fileDetails: ( | ||
file: File(icalPath), | ||
mimeType: 'text/calendar', | ||
), | ||
refDetails: refDetails, | ||
internalLink: internalLink, | ||
shareContentBuilder: () => refDetails.generateExternalLink(), | ||
fileDetailContentBuilder: () async { | ||
final filename = | ||
event.title().replaceAll(RegExp(r'[^A-Za-z0-9_-]'), '_'); | ||
final tempDir = await getTemporaryDirectory(); | ||
final icalPath = join(tempDir.path, '$filename.ics'); | ||
event.icalForSharing(icalPath); | ||
return ( | ||
file: File(icalPath), | ||
mimeType: 'text/calendar', | ||
); | ||
}, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General code optimisation based on the above mentioned changes.
return ExternalShareOptions( | ||
qrContent: qrContent, | ||
shareContentBuilder: () async => shareContent, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used ExternalShareOptions
common widget here also for user invites. This make sharing option more generic and removal of code duplication.
await openShareSpaceObjectDialog( | ||
context: context, | ||
refDetails: refDetails, | ||
internalLink: internalLink, | ||
shareContentBuilder: () => refDetails.generateExternalLink(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only change, other changes showing in this file are only related Code Format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But shouldn't we also close the share-dialog when someone clicked any of the things?
required BuildContext context, | ||
required String text, | ||
}) async { | ||
if (Platform.isAndroid) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually do the path of only showing features if they are available - if this isn't possible on iOS rather than showing some error messages, the button should not show up.
app/lib/common/widgets/share/widgets/external_share_options.dart
Outdated
Show resolved
Hide resolved
Due to common usage of But ya after changes related to Did required changes and pushed the code. |
This PR contains general code improve in Space Object Sharing code and enhancement of sharing options by enabling External Sharing Options.
Screen.Recording.2025-01-03.at.10.36.06.AM.mov
Also, User invite share screen now used common sharing UI-UX.
Screen.Recording.2025-01-03.at.10.37.43.AM.mov