Skip to content

Commit 00cbbf8

Browse files
CubeRomanMagellanMagellan
andauthored
SK-648: Image share does not work (#111)
* minor fix buildChatMessageModels * fix ios screenshot share * fix to not save draft while sharing --------- Co-authored-by: Magellan <magellan@connectycube.com>
1 parent a2e00f3 commit 00cbbf8

8 files changed

Lines changed: 26 additions & 57 deletions

File tree

sama_chat_client/ios/Podfile.lock

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,6 @@ PODS:
33
- Flutter
44
- connectivity_plus (0.0.1):
55
- Flutter
6-
- DKImagePickerController/Core (4.3.9):
7-
- DKImagePickerController/ImageDataManager
8-
- DKImagePickerController/Resource
9-
- DKImagePickerController/ImageDataManager (4.3.9)
10-
- DKImagePickerController/PhotoGallery (4.3.9):
11-
- DKImagePickerController/Core
12-
- DKPhotoGallery
13-
- DKImagePickerController/Resource (4.3.9)
14-
- DKPhotoGallery (0.0.19):
15-
- DKPhotoGallery/Core (= 0.0.19)
16-
- DKPhotoGallery/Model (= 0.0.19)
17-
- DKPhotoGallery/Preview (= 0.0.19)
18-
- DKPhotoGallery/Resource (= 0.0.19)
19-
- SDWebImage
20-
- SwiftyGif
21-
- DKPhotoGallery/Core (0.0.19):
22-
- DKPhotoGallery/Model
23-
- DKPhotoGallery/Preview
24-
- SDWebImage
25-
- SwiftyGif
26-
- DKPhotoGallery/Model (0.0.19):
27-
- SDWebImage
28-
- SwiftyGif
29-
- DKPhotoGallery/Preview (0.0.19):
30-
- DKPhotoGallery/Model
31-
- DKPhotoGallery/Resource
32-
- SDWebImage
33-
- SwiftyGif
34-
- DKPhotoGallery/Resource (0.0.19):
35-
- SDWebImage
36-
- SwiftyGif
37-
- file_picker (0.0.1):
38-
- DKImagePickerController/PhotoGallery
39-
- Flutter
406
- Firebase/CoreOnly (11.15.0):
417
- FirebaseCore (~> 11.15.0)
428
- Firebase/Messaging (11.15.0):
@@ -109,6 +75,8 @@ PODS:
10975
- GoogleUtilities/UserDefaults (8.1.0):
11076
- GoogleUtilities/Logger
11177
- GoogleUtilities/Privacy
78+
- image_picker_ios (0.0.1):
79+
- Flutter
11280
- libwebp (1.5.0):
11381
- libwebp/demux (= 1.5.0)
11482
- libwebp/mux (= 1.5.0)
@@ -153,7 +121,6 @@ PODS:
153121
- sqflite_darwin (0.0.4):
154122
- Flutter
155123
- FlutterMacOS
156-
- SwiftyGif (5.4.5)
157124
- url_launcher_ios (0.0.1):
158125
- Flutter
159126
- video_compress (0.3.0):
@@ -167,14 +134,14 @@ PODS:
167134
DEPENDENCIES:
168135
- app_set_id (from `.symlinks/plugins/app_set_id/ios`)
169136
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
170-
- file_picker (from `.symlinks/plugins/file_picker/ios`)
171137
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
172138
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
173139
- Flutter (from `Flutter`)
174140
- flutter_image_compress_common (from `.symlinks/plugins/flutter_image_compress_common/ios`)
175141
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
176142
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
177143
- get_thumbnail_video (from `.symlinks/plugins/get_thumbnail_video/ios`)
144+
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
178145
- objectbox_flutter_libs (from `.symlinks/plugins/objectbox_flutter_libs/ios`)
179146
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
180147
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
@@ -188,8 +155,6 @@ DEPENDENCIES:
188155

189156
SPEC REPOS:
190157
trunk:
191-
- DKImagePickerController
192-
- DKPhotoGallery
193158
- Firebase
194159
- FirebaseCore
195160
- FirebaseCoreInternal
@@ -204,15 +169,12 @@ SPEC REPOS:
204169
- PromisesObjC
205170
- SDWebImage
206171
- SDWebImageWebPCoder
207-
- SwiftyGif
208172

209173
EXTERNAL SOURCES:
210174
app_set_id:
211175
:path: ".symlinks/plugins/app_set_id/ios"
212176
connectivity_plus:
213177
:path: ".symlinks/plugins/connectivity_plus/ios"
214-
file_picker:
215-
:path: ".symlinks/plugins/file_picker/ios"
216178
firebase_core:
217179
:path: ".symlinks/plugins/firebase_core/ios"
218180
firebase_messaging:
@@ -227,6 +189,8 @@ EXTERNAL SOURCES:
227189
:path: ".symlinks/plugins/flutter_secure_storage/ios"
228190
get_thumbnail_video:
229191
:path: ".symlinks/plugins/get_thumbnail_video/ios"
192+
image_picker_ios:
193+
:path: ".symlinks/plugins/image_picker_ios/ios"
230194
objectbox_flutter_libs:
231195
:path: ".symlinks/plugins/objectbox_flutter_libs/ios"
232196
package_info_plus:
@@ -251,9 +215,6 @@ EXTERNAL SOURCES:
251215
SPEC CHECKSUMS:
252216
app_set_id: 0e0db3830db2bca1b67eecec1e2ab80b2bec48fa
253217
connectivity_plus: 2a701ffec2c0ae28a48cf7540e279787e77c447d
254-
DKImagePickerController: 946cec48c7873164274ecc4624d19e3da4c1ef3c
255-
DKPhotoGallery: b3834fecb755ee09a593d7c9e389d8b5d6deed60
256-
file_picker: b159e0c068aef54932bb15dc9fd1571818edaf49
257218
Firebase: d99ac19b909cd2c548339c2241ecd0d1599ab02e
258219
firebase_core: 99a37263b3c27536063a7b601d9e2a49400a433c
259220
firebase_messaging: bf6697c61f31c7cc0f654131212ff04c0115c2c7
@@ -268,6 +229,7 @@ SPEC CHECKSUMS:
268229
get_thumbnail_video: b9a180957daed3e9179e66268db51d8798e41f65
269230
GoogleDataTransport: aae35b7ea0c09004c3797d53c8c41f66f219d6a7
270231
GoogleUtilities: 00c88b9a86066ef77f0da2fab05f65d7768ed8e1
232+
image_picker_ios: 4f2f91b01abdb52842a8e277617df877e40f905b
271233
libwebp: 02b23773aedb6ff1fd38cec7a77b81414c6842a8
272234
Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d
273235
nanopb: fad817b59e0457d11a5dfbde799381cd727c1275
@@ -281,7 +243,6 @@ SPEC CHECKSUMS:
281243
SDWebImageWebPCoder: e38c0a70396191361d60c092933e22c20d5b1380
282244
shared_preferences_foundation: 5086985c1d43c5ba4d5e69a4e8083a389e2909e6
283245
sqflite_darwin: 5a7236e3b501866c1c9befc6771dfd73ffb8702d
284-
SwiftyGif: 706c60cf65fa2bc5ee0313beece843c8eb8194d4
285246
url_launcher_ios: bb13df5870e8c4234ca12609d04010a21be43dfa
286247
video_compress: fce97e4fb1dfd88175aa07d2ffc8a2f297f87fbe
287248
video_player_avfoundation: 7993f492ae0bd77edaea24d9dc051d8bb2cd7c86

sama_chat_client/ios/Share Extension/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
1616
<integer>1</integer>
1717
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
18-
<integer>100</integer>
18+
<integer>10</integer>
1919
</dict>
2020
</dict>
2121
<key>NSExtensionMainStoryboard</key>

sama_chat_client/lib/src/features/conversation/bloc/conversation_bloc.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,17 +552,18 @@ class ConversationBloc extends Bloc<ConversationEvent, ConversationState> {
552552
? messages.tryGet(messages.length - 2)
553553
: messages.tryGet(messages.length - 1);
554554

555-
var shouldUpdate = state.messages.isNotEmpty &&
556-
lastCurrentMsg != null &&
557-
lastCurrentMsg.id != state.messages.lastOrNull?.id;
555+
var shouldUpdate = state.messages.isNotEmpty;
558556

559-
var lastPrevMsg = shouldUpdate ? state.messages.last : null;
557+
var lastPrevMsg = state.messages.lastOrNull;
558+
var firstPrevMsg = state.messages.firstOrNull;
560559

561560
for (int i = 0; i < messages.length; i++) {
562561
var message = messages[i];
563562
var chatMessage = message.toChatMessage(
564563
i == 0
565-
? lastPrevMsg?.from != messages[i].from
564+
? lastPrevMsg == firstPrevMsg ||
565+
lastPrevMsg?.id == lastCurrentMsg?.id ||
566+
lastPrevMsg?.from != messages[i].from
566567
: isServiceMessage(messages[i - 1]) ||
567568
messages[i - 1].from != messages[i].from,
568569
i == messages.length - 1 ||

sama_chat_client/lib/src/features/conversation/bloc/send_message/send_message_bloc.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class SendMessageBloc extends Bloc<SendMessageEvent, SendMessageState> {
101101
emit(state.copyWith(
102102
isTextEmpty: event.text.trim().isEmpty,
103103
text: event.text,
104+
safeDraft: event.safeDraft,
104105
status: SendMessageStatus.initial));
105106
}
106107

@@ -167,7 +168,7 @@ class SendMessageBloc extends Bloc<SendMessageEvent, SendMessageState> {
167168
}
168169

169170
saveDraftIfExist() {
170-
if (state.text.isNotEmpty) {
171+
if (state.text.isNotEmpty && state.safeDraft) {
171172
messagesRepository.saveDraftMessage(
172173
state.text, currentConversation.id, state.replyMessage);
173174
}

sama_chat_client/lib/src/features/conversation/bloc/send_message/send_message_event.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ final class SendTextMessage extends SendMessageEvent {
1515

1616
final class TextMessageChanged extends SendMessageEvent {
1717
final String text;
18+
final bool safeDraft;
1819

19-
const TextMessageChanged(this.text);
20+
const TextMessageChanged(this.text, {this.safeDraft = true});
2021
}
2122

2223
final class TextMessageClear extends SendMessageEvent {

sama_chat_client/lib/src/features/conversation/bloc/send_message/send_message_state.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ final class SendMessageState extends Equatable {
88
this.isTextEmpty = true,
99
this.text = '',
1010
this.scroll = false,
11+
this.safeDraft = true,
1112
this.errorMessage,
1213
this.draftMessage,
1314
this.replyMessage,
@@ -18,6 +19,7 @@ final class SendMessageState extends Equatable {
1819
final bool isTextEmpty;
1920
final String text;
2021
final bool scroll;
22+
final bool safeDraft;
2123
final String? errorMessage;
2224
final MessageModel? draftMessage;
2325
final MessageModel? replyMessage;
@@ -28,6 +30,7 @@ final class SendMessageState extends Equatable {
2830
bool? isTextEmpty,
2931
String? text,
3032
bool? scroll,
33+
bool? safeDraft,
3134
String? errorMessage,
3235
MessageModel? Function()? draftMessage,
3336
MessageModel? Function()? replyMessage,
@@ -38,6 +41,7 @@ final class SendMessageState extends Equatable {
3841
isTextEmpty: isTextEmpty ?? this.isTextEmpty,
3942
text: text ?? this.text,
4043
scroll: scroll ?? this.scroll,
44+
safeDraft: safeDraft ?? this.safeDraft,
4145
errorMessage: errorMessage ?? this.errorMessage,
4246
draftMessage: draftMessage != null ? draftMessage() : this.draftMessage,
4347
replyMessage: replyMessage != null ? replyMessage() : this.replyMessage,
@@ -56,6 +60,7 @@ final class SendMessageState extends Equatable {
5660
isTextEmpty,
5761
text,
5862
scroll,
63+
safeDraft,
5964
errorMessage,
6065
draftMessage,
6166
replyMessage,

sama_chat_client/lib/src/features/conversation/view/message_input.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ class _MessageInputState extends State<MessageInput> {
5353

5454
if (widget.sharedMessage?.type == SharedMediaType.text ||
5555
widget.sharedMessage?.type == SharedMediaType.url) {
56-
BlocProvider.of<SendMessageBloc>(context)
57-
.add(TextMessageChanged(widget.sharedMessage!.path));
56+
BlocProvider.of<SendMessageBloc>(context).add(
57+
TextMessageChanged(widget.sharedMessage!.path, safeDraft: false));
5858
}
5959
return MultiBlocListener(
6060
listeners: [

sama_chat_client/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ dependencies:
4545
# receive_sharing_intent: ^1.8.1
4646
receive_sharing_intent:
4747
git:
48-
url: https://github.com/KasemJaffer/receive_sharing_intent
49-
ref: 2cea396843cd3ab1b5ec4334be4233864637874e
48+
url: https://github.com/CubeRomanMagellan/receive_sharing_intent
49+
ref: 9019083edf3ad8232076d8cc82933709f0003220
5050
sama_sdk:
5151
path: ../sama_sdk
5252
scrollable_positioned_list: ^0.3.8

0 commit comments

Comments
 (0)