From 35c4ddd155d9192486faa45a86d1dcd9c08bfd69 Mon Sep 17 00:00:00 2001 From: Decoder07 Date: Mon, 8 Jan 2024 18:44:43 +0530 Subject: [PATCH] Fixed pinned message bug on iOS --- .../hls_viewer/overlay_chat_component.dart | 100 ++++++--- .../bottom_sheets/chat_bottom_sheet.dart | 6 +- .../widgets/chat_widgets/pin_chat_widget.dart | 207 +++++++++--------- .../src/widgets/toasts/hms_error_toast.dart | 6 +- .../lib/src/widgets/toasts/hms_toast.dart | 1 + .../example/ExampleAppChangelog.txt | 6 + .../example/android/app/build.gradle | 4 +- .../hmssdk_flutter/example/ios/Gemfile.lock | 12 +- .../Actions/HMSSessionStoreAction.swift | 2 + .../Classes/SwiftHmssdkFlutterPlugin.swift | 2 + packages/hmssdk_flutter/pubspec.lock | 26 +-- 11 files changed, 218 insertions(+), 154 deletions(-) diff --git a/packages/hms_room_kit/lib/src/hls_viewer/overlay_chat_component.dart b/packages/hms_room_kit/lib/src/hls_viewer/overlay_chat_component.dart index 296cb36de..3c1b4d4db 100644 --- a/packages/hms_room_kit/lib/src/hls_viewer/overlay_chat_component.dart +++ b/packages/hms_room_kit/lib/src/hls_viewer/overlay_chat_component.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_linkify/flutter_linkify.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:hms_room_kit/src/widgets/bottom_sheets/chat_utilities_bottom_sheet.dart'; import 'package:hms_room_kit/src/widgets/chat_widgets/chat_text_field.dart'; import 'package:hms_room_kit/src/widgets/chat_widgets/pin_chat_widget.dart'; import 'package:hmssdk_flutter/hmssdk_flutter.dart'; @@ -74,39 +75,78 @@ class _OverlayChatComponentState extends State { shrinkWrap: true, itemCount: data.item1.length, itemBuilder: (_, index) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, + return Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - HMSTitleText( - text: data.item1[index].sender?.name ?? - "Anonymous", - textColor: Colors.white, - fontSize: 14, - lineHeight: 20, - letterSpacing: 0.1, - ), - const SizedBox( - height: 2, + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + HMSTitleText( + text: data.item1[index].sender?.name ?? + "Anonymous", + textColor: Colors.white, + fontSize: 14, + lineHeight: 20, + letterSpacing: 0.1, + ), + const SizedBox( + height: 2, + ), + SelectableLinkify( + text: data.item1[index].message, + onOpen: (link) async { + Uri url = Uri.parse(link.url); + if (await canLaunchUrl(url)) { + await launchUrl(url, + mode: LaunchMode + .externalApplication); + } + }, + scrollPhysics: + const NeverScrollableScrollPhysics(), + options: + const LinkifyOptions(humanize: false), + style: HMSTextStyle.setTextStyle( + color: Colors.white, + fontSize: 14, + height: 20 / 14, + letterSpacing: 0.25, + ), + ), + const SizedBox( + height: 8, + ) + ], + ), ), - SelectableLinkify( - text: data.item1[index].message, - onOpen: (link) async { - Uri url = Uri.parse(link.url); - if (await canLaunchUrl(url)) { - await launchUrl(url, - mode: LaunchMode.externalApplication); - } + GestureDetector( + onTap: () { + showModalBottomSheet( + isScrollControlled: true, + backgroundColor: HMSThemeColors.surfaceDim, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(16), + topRight: Radius.circular(16)), + ), + context: context, + builder: (ctx) => + ChangeNotifierProvider.value( + value: context.read(), + child: ChatUtilitiesBottomSheet( + message: data.item1[index], + )), + ); }, - options: const LinkifyOptions(humanize: false), - style: HMSTextStyle.setTextStyle( - color: Colors.white, - fontSize: 14, - height: 20 / 14, - letterSpacing: 0.25, + child: SvgPicture.asset( + "packages/hms_room_kit/lib/src/assets/icons/more.svg", + height: 20, + width: 20, + colorFilter: ColorFilter.mode( + HMSThemeColors.onSurfaceMediumEmphasis, + BlendMode.srcIn), ), - ), - const SizedBox( - height: 8, ) ], ); @@ -124,7 +164,7 @@ class _OverlayChatComponentState extends State { meetingStore.pinnedMessages.length), builder: (_, data, __) { return PinChatWidget( - pinnedMessage: data.item1, + pinnedMessage: data.item1.reversed.toList(), backgroundColor: HMSThemeColors.backgroundDim.withAlpha(64), ); }), diff --git a/packages/hms_room_kit/lib/src/widgets/bottom_sheets/chat_bottom_sheet.dart b/packages/hms_room_kit/lib/src/widgets/bottom_sheets/chat_bottom_sheet.dart index 3ec06526b..4185d0249 100644 --- a/packages/hms_room_kit/lib/src/widgets/bottom_sheets/chat_bottom_sheet.dart +++ b/packages/hms_room_kit/lib/src/widgets/bottom_sheets/chat_bottom_sheet.dart @@ -100,9 +100,9 @@ class _ChatBottomSheetState extends State { child: Center(child: HMSEmptyChatWidget())) : Expanded( child: Column(children: [ - ///If there is a pinned chat - if (data.item3.isNotEmpty) - PinChatWidget(pinnedMessage: data.item3), + PinChatWidget( + pinnedMessage: + data.item3.reversed.toList()), /// List containing chats Expanded( diff --git a/packages/hms_room_kit/lib/src/widgets/chat_widgets/pin_chat_widget.dart b/packages/hms_room_kit/lib/src/widgets/chat_widgets/pin_chat_widget.dart index 4998eac4c..15690750f 100644 --- a/packages/hms_room_kit/lib/src/widgets/chat_widgets/pin_chat_widget.dart +++ b/packages/hms_room_kit/lib/src/widgets/chat_widgets/pin_chat_widget.dart @@ -57,109 +57,118 @@ class _PinChatWidgetState extends State { @override Widget build(BuildContext context) { - return GestureDetector( - onTap: () => toggleExpand(), - child: Padding( - padding: const EdgeInsets.only(bottom: 8.0), - child: Row( - children: [ - AnimatedContainer( - height: MediaQuery.of(context).size.height * - (isExpanded ? 0.13 : 0.07), - width: (HMSRoomLayout.chatData?.allowPinningMessages ?? false) - ? MediaQuery.of(context).size.width * 0.85 - : MediaQuery.of(context).size.width * 0.9, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8), - color: - widget.backgroundColor ?? HMSThemeColors.surfaceDefault), - duration: const Duration(milliseconds: 0), - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - if (widget.pinnedMessage.length > 1) - DotsIndicator( - axis: Axis.vertical, - mainAxisSize: MainAxisSize.min, - dotsCount: widget.pinnedMessage.length, - position: currentPage > widget.pinnedMessage.length - ? 0 - : currentPage, - decorator: DotsDecorator( - spacing: const EdgeInsets.only(bottom: 3.0, right: 8), - size: Size(2.0, isExpanded ? 24 : 9.0), - activeSize: Size(2.0, isExpanded ? 24 : 9.0), - color: HMSThemeColors.onSurfaceLowEmphasis, - activeColor: HMSThemeColors.onSurfaceHighEmphasis, - activeShape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16.0)), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16.0)), - ), - onTap: (position) => setCurrentPage(position), - ), - Expanded( - child: PageView.builder( - scrollDirection: Axis.vertical, - controller: _pageController, - itemCount: widget.pinnedMessage.length, - physics: const PageScrollPhysics(), - onPageChanged: (value) => setCurrentPage(value), - itemBuilder: (context, index) => SelectableLinkify( - maxLines: 2, - scrollPhysics: isExpanded - ? const BouncingScrollPhysics() - : const NeverScrollableScrollPhysics(), - text: widget.pinnedMessage[index]["text"], - onOpen: (link) async { - Uri url = Uri.parse(link.url); - if (await canLaunchUrl(url)) { - await launchUrl(url, - mode: LaunchMode.externalApplication); - } - }, - onTap: () => toggleExpand(), - options: const LinkifyOptions(humanize: false), - style: HMSTextStyle.setTextStyle( - fontSize: 14.0, - color: HMSThemeColors.onSurfaceHighEmphasis, - letterSpacing: 0.25, - height: 20 / 14, - fontWeight: FontWeight.w400, + ///If there are no pinnedMessage we render an empty SizedBox + ///else we render the pinned message widget + return widget.pinnedMessage.isEmpty + ? const SizedBox() + : GestureDetector( + onTap: () => toggleExpand(), + child: Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: Row( + children: [ + AnimatedContainer( + height: MediaQuery.of(context).size.height * + (isExpanded ? 0.13 : 0.07), + width: + (HMSRoomLayout.chatData?.allowPinningMessages ?? false) + ? MediaQuery.of(context).size.width * 0.85 + : MediaQuery.of(context).size.width * 0.9, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8), + color: widget.backgroundColor ?? + HMSThemeColors.surfaceDefault), + duration: const Duration(milliseconds: 0), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + if (widget.pinnedMessage.length > 1) + DotsIndicator( + axis: Axis.vertical, + mainAxisSize: MainAxisSize.min, + dotsCount: widget.pinnedMessage.length, + position: + currentPage > widget.pinnedMessage.length + ? 0 + : currentPage, + decorator: DotsDecorator( + spacing: const EdgeInsets.only( + bottom: 3.0, right: 8), + size: Size(2.0, isExpanded ? 24 : 9.0), + activeSize: Size(2.0, isExpanded ? 24 : 9.0), + color: HMSThemeColors.onSurfaceLowEmphasis, + activeColor: + HMSThemeColors.onSurfaceHighEmphasis, + activeShape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16.0)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16.0)), + ), + onTap: (position) => setCurrentPage(position), + ), + Expanded( + child: PageView.builder( + scrollDirection: Axis.vertical, + controller: _pageController, + itemCount: widget.pinnedMessage.length, + physics: const PageScrollPhysics(), + onPageChanged: (value) => setCurrentPage(value), + itemBuilder: (context, index) => + SelectableLinkify( + maxLines: 2, + scrollPhysics: isExpanded + ? const BouncingScrollPhysics() + : const NeverScrollableScrollPhysics(), + text: widget.pinnedMessage[index]["text"], + onOpen: (link) async { + Uri url = Uri.parse(link.url); + if (await canLaunchUrl(url)) { + await launchUrl(url, + mode: LaunchMode.externalApplication); + } + }, + onTap: () => toggleExpand(), + options: const LinkifyOptions(humanize: false), + style: HMSTextStyle.setTextStyle( + fontSize: 14.0, + color: HMSThemeColors.onSurfaceHighEmphasis, + letterSpacing: 0.25, + height: 20 / 14, + fontWeight: FontWeight.w400, + ), + linkStyle: HMSTextStyle.setTextStyle( + fontSize: 14.0, + color: HMSThemeColors.primaryDefault, + letterSpacing: 0.25, + height: 20 / 14, + fontWeight: FontWeight.w400), + ), + ), ), - linkStyle: HMSTextStyle.setTextStyle( - fontSize: 14.0, - color: HMSThemeColors.primaryDefault, - letterSpacing: 0.25, - height: 20 / 14, - fontWeight: FontWeight.w400), - ), + ], + ), + ), + ), + const SizedBox(width: 8), + if (HMSRoomLayout.chatData?.allowPinningMessages ?? false) + GestureDetector( + onTap: () => context.read().unpinMessage( + widget.pinnedMessage[currentPage]["id"]), + child: SvgPicture.asset( + "packages/hms_room_kit/lib/src/assets/icons/unpin.svg", + height: 20, + width: 20, + colorFilter: ColorFilter.mode( + HMSThemeColors.onSurfaceMediumEmphasis, + BlendMode.srcIn), ), ), - ], - ), + ], ), ), - const SizedBox(width: 8), - if (HMSRoomLayout.chatData?.allowPinningMessages ?? false) - GestureDetector( - onTap: () => context - .read() - .unpinMessage(widget.pinnedMessage[currentPage]["id"]), - child: SvgPicture.asset( - "packages/hms_room_kit/lib/src/assets/icons/unpin.svg", - height: 20, - width: 20, - colorFilter: ColorFilter.mode( - HMSThemeColors.onSurfaceMediumEmphasis, BlendMode.srcIn), - ), - ), - ], - ), - ), - ); + ); } } diff --git a/packages/hms_room_kit/lib/src/widgets/toasts/hms_error_toast.dart b/packages/hms_room_kit/lib/src/widgets/toasts/hms_error_toast.dart index 56d8494f4..a57d87924 100644 --- a/packages/hms_room_kit/lib/src/widgets/toasts/hms_error_toast.dart +++ b/packages/hms_room_kit/lib/src/widgets/toasts/hms_error_toast.dart @@ -1,3 +1,6 @@ +///Dart imports +import 'dart:math' as math; + ///Package imports import 'package:flutter/material.dart'; import 'package:hmssdk_flutter/hmssdk_flutter.dart'; @@ -28,7 +31,8 @@ class HMSErrorToast extends StatelessWidget { toastColor: toastColor, toastPosition: toastPosition, subtitle: HMSSubheadingText( - text: error.description, + text: error.description + .substring(0, math.min(50, error.description.length)), textColor: HMSThemeColors.onSurfaceHighEmphasis, fontWeight: FontWeight.w600, letterSpacing: 0.1, diff --git a/packages/hms_room_kit/lib/src/widgets/toasts/hms_toast.dart b/packages/hms_room_kit/lib/src/widgets/toasts/hms_toast.dart index 814d1cd5e..392fd66bc 100644 --- a/packages/hms_room_kit/lib/src/widgets/toasts/hms_toast.dart +++ b/packages/hms_room_kit/lib/src/widgets/toasts/hms_toast.dart @@ -37,6 +37,7 @@ class _HMSToastState extends State { return Padding( padding: EdgeInsets.only(bottom: widget.toastPosition ?? 68), child: AlertDialog( + backgroundColor: widget.toastColor, insetPadding: const EdgeInsets.all(0), alignment: Alignment.bottomCenter, contentPadding: const EdgeInsets.all(0), diff --git a/packages/hmssdk_flutter/example/ExampleAppChangelog.txt b/packages/hmssdk_flutter/example/ExampleAppChangelog.txt index 027c108e5..2ebf4dc92 100644 --- a/packages/hmssdk_flutter/example/ExampleAppChangelog.txt +++ b/packages/hmssdk_flutter/example/ExampleAppChangelog.txt @@ -15,6 +15,12 @@ https://100ms.atlassian.net/browse/LIVE-1981 - Block Peer From Chat https://100ms.atlassian.net/browse/FLUT-157 +- Multi Pin Chat +https://100ms.atlassian.net/browse/FLUT-154 + +- can't see pinned chat(by remote peer) on Flutter +https://100ms.atlassian.net/browse/FLUT-187 + Room Kit: 1.0.9 Core SDK: 1.9.6 Android SDK: 2.8.4 diff --git a/packages/hmssdk_flutter/example/android/app/build.gradle b/packages/hmssdk_flutter/example/android/app/build.gradle index e9de7e70e..d4876a003 100644 --- a/packages/hmssdk_flutter/example/android/app/build.gradle +++ b/packages/hmssdk_flutter/example/android/app/build.gradle @@ -32,8 +32,8 @@ android { applicationId "live.hms.flutter" minSdkVersion 21 targetSdkVersion 33 - versionCode 414 - versionName "1.5.114" + versionCode 415 + versionName "1.5.115" } signingConfigs { diff --git a/packages/hmssdk_flutter/example/ios/Gemfile.lock b/packages/hmssdk_flutter/example/ios/Gemfile.lock index 762fb1264..d23efec30 100644 --- a/packages/hmssdk_flutter/example/ios/Gemfile.lock +++ b/packages/hmssdk_flutter/example/ios/Gemfile.lock @@ -13,13 +13,13 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.3.0) - aws-partitions (1.875.0) + aws-partitions (1.877.0) aws-sdk-core (3.190.1) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.8) jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.75.0) + aws-sdk-kms (1.76.0) aws-sdk-core (~> 3, >= 3.188.0) aws-sigv4 (~> 1.1) aws-sdk-s3 (1.142.0) @@ -41,7 +41,7 @@ GEM domain_name (0.6.20231109) dotenv (2.8.1) emoji_regex (3.2.3) - excon (0.108.0) + excon (0.109.0) faraday (1.10.3) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) @@ -71,7 +71,7 @@ GEM faraday_middleware (1.2.0) faraday (~> 1.0) fastimage (2.3.0) - fastlane (2.217.0) + fastlane (2.218.0) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.8, < 3.0.0) artifactory (~> 3.0) @@ -98,7 +98,7 @@ GEM mini_magick (>= 4.9.4, < 5.0.0) multipart-post (>= 2.0.0, < 3.0.0) naturally (~> 2.2) - optparse (~> 0.1.1) + optparse (>= 0.1.1) plist (>= 3.1.0, < 4.0.0) rubyzip (>= 2.0.0, < 3.0.0) security (= 0.1.3) @@ -171,7 +171,7 @@ GEM multipart-post (2.3.0) nanaimo (0.3.0) naturally (2.2.1) - optparse (0.1.1) + optparse (0.4.0) os (1.1.4) plist (3.7.1) public_suffix (5.0.4) diff --git a/packages/hmssdk_flutter/ios/Classes/Actions/HMSSessionStoreAction.swift b/packages/hmssdk_flutter/ios/Classes/Actions/HMSSessionStoreAction.swift index 42b52794d..5bf8c16ee 100644 --- a/packages/hmssdk_flutter/ios/Classes/Actions/HMSSessionStoreAction.swift +++ b/packages/hmssdk_flutter/ios/Classes/Actions/HMSSessionStoreAction.swift @@ -71,6 +71,8 @@ class HMSSessionStoreAction { } else if let boolValue = value as? Bool{ let stringValue = String(boolValue) result(HMSResultExtension.toDictionary(true, stringValue)) + } else if (value == nil || value is NSNull){ + result(HMSResultExtension.toDictionary(true, nil)) } else{ HMSErrorLogger.logError(#function, "Session metadata type is not compatible, Please use compatible type while setting metadata", "Type Incompatibility Error") diff --git a/packages/hmssdk_flutter/ios/Classes/SwiftHmssdkFlutterPlugin.swift b/packages/hmssdk_flutter/ios/Classes/SwiftHmssdkFlutterPlugin.swift index 7100fae6f..ef9e71cb5 100644 --- a/packages/hmssdk_flutter/ios/Classes/SwiftHmssdkFlutterPlugin.swift +++ b/packages/hmssdk_flutter/ios/Classes/SwiftHmssdkFlutterPlugin.swift @@ -566,6 +566,8 @@ public class SwiftHmssdkFlutterPlugin: NSObject, FlutterPlugin, HMSUpdateListene dict["value"] = stringValue } else if let boolValue = value as? Bool{ dict["value"] = String(boolValue) + } else if (value == nil || value is NSNull) { + dict["value"] = nil } else{ HMSErrorLogger.logError(#function, "Session metadata type is not compatible, Please use compatible type while setting metadata", "Type Incompatibility Error") diff --git a/packages/hmssdk_flutter/pubspec.lock b/packages/hmssdk_flutter/pubspec.lock index 53939cd59..c3cc2c33e 100644 --- a/packages/hmssdk_flutter/pubspec.lock +++ b/packages/hmssdk_flutter/pubspec.lock @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.17.2" fake_async: dependency: transitive description: @@ -79,10 +79,10 @@ packages: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.9.1" path: dependency: transitive description: @@ -108,18 +108,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.1" string_scanner: dependency: transitive description: @@ -140,10 +140,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.6.0" vector_math: dependency: transitive description: @@ -156,10 +156,10 @@ packages: dependency: transitive description: name: web - sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 url: "https://pub.dev" source: hosted - version: "0.3.0" + version: "0.1.4-beta" sdks: - dart: ">=3.2.0-194.0.dev <4.0.0" + dart: ">=3.1.0-185.0.dev <4.0.0" flutter: ">=2.10.0"