Skip to content

Commit

Permalink
fixup! TF-3260 Load & Display App Grid Linagora Ecosystem
Browse files Browse the repository at this point in the history
  • Loading branch information
dab246 committed Dec 9, 2024
1 parent e38afd9 commit c20e13b
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 17 deletions.
30 changes: 26 additions & 4 deletions core/lib/presentation/views/image/image_loader_mixin.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/utils/app_logger.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

Expand All @@ -9,17 +10,38 @@ mixin ImageLoaderMixin {
required String imagePath,
double? imageSize
}) {
if (isImageNetworkLink(imagePath)) {
if (isImageNetworkLink(imagePath) && isImageSVG(imagePath)) {
return SvgPicture.network(
imagePath,
width: imageSize ?? 150,
height: imageSize ?? 150,
fit: BoxFit.fill,
placeholderBuilder: (_) {
return const CupertinoActivityIndicator();
},
);
} else if (isImageNetworkLink(imagePath)) {
return Image.network(
imagePath,
fit: BoxFit.fill,
width: imageSize ?? 150,
height: imageSize ?? 150,
errorBuilder: (_, __, ___) {
loadingBuilder: (_, child, loadingProgress) {
if (loadingProgress != null &&
loadingProgress.cumulativeBytesLoaded != loadingProgress.expectedTotalBytes) {
return const Center(
child: CupertinoActivityIndicator(),
);
}
return child;
},
errorBuilder: (context, error, stackTrace) {
logError('ImageLoaderMixin::buildImage:Exception = $error');
return Container(
width: imageSize ?? 150,
height: imageSize ?? 150,
color: AppColor.textFieldHintColor,
alignment: Alignment.center,
child: const Icon(Icons.error_outline),
);
},
);
Expand Down
29 changes: 17 additions & 12 deletions lib/features/base/mixin/launcher_application_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import 'package:core/utils/platform_info.dart';
import 'package:core/utils/string_convert.dart';
import 'package:external_app_launcher/external_app_launcher.dart';
import 'package:rich_text_composer/views/commons/logger.dart';
import 'package:url_launcher/url_launcher.dart' as launcher;

mixin LauncherApplicationMixin {
Expand All @@ -12,18 +13,22 @@ mixin LauncherApplicationMixin {
String? iosStoreLink,
Uri? uri,
}) async {
if (PlatformInfo.isWeb && uri != null) {
await openWebApplication(uri);
} else if (PlatformInfo.isAndroid && androidPackageId != null) {
await openAndroidApplication(androidPackageId);
} else if (PlatformInfo.isIOS &&
(iosScheme != null || iosStoreLink != null)) {
await openIOSApplication(
iosScheme,
iosStoreLink,
);
} else if (uri != null) {
await openOtherApplication(uri);
try {
if (PlatformInfo.isWeb && uri != null) {
await openWebApplication(uri);
} else if (PlatformInfo.isAndroid && androidPackageId != null) {
await openAndroidApplication(androidPackageId);
} else if (PlatformInfo.isIOS &&
(iosScheme != null || iosStoreLink != null)) {
await openIOSApplication(
iosScheme,
iosStoreLink,
);
} else if (uri != null) {
await openOtherApplication(uri);
}
} catch (e) {
logError('LauncherApplicationMixin::launchApplication:Exception = $e');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ class AppLinagoraEcosystem extends LinagoraEcosystemProperties {

Uri? get appRedirectLink => webLink;

bool get isAppIOSEnabled => iosUrlScheme?.isNotEmpty == true ||
iosAppStoreLink?.isNotEmpty == true ||
appRedirectLink != null;

bool get isAppAndroidEnabled => androidPackageId?.isNotEmpty == true ||
appRedirectLink != null;

@override
List<Object?> get props => [
appName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@ extension LinagoraEcosystemExtension on LinagoraEcosystem {

return listWebAppLinagora + listMobileAppLinagora;
}

List<AppLinagoraEcosystem> get listAppLinagoraEcosystemOnIOS {
return listAppLinagoraEcosystem.where((app) => app.isAppIOSEnabled).toList();
}

List<AppLinagoraEcosystem> get listAppLinagoraEcosystemOnAndroid {
return listAppLinagoraEcosystem.where((app) => app.isAppAndroidEnabled).toList();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:core/utils/platform_info.dart';
import 'package:dartz/dartz.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/linagora_ecosystem/app_linagora_ecosystem.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/linagora_ecosystem/linagora_ecosystem.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/repository/app_grid_repository.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/state/get_app_grid_linagora_ecosystem_state.dart';
Expand All @@ -14,7 +16,13 @@ class GetAppGridLinagraEcosystemInteractor {
try {
yield Right(LoadingAppGridLinagraEcosystem());
final linagoraEcosystem = await _appGridRepository.getLinagoraEcosystem(baseUrl);
yield Right(GetAppGridLinagraEcosystemSuccess(linagoraEcosystem.listAppLinagoraEcosystem));
List<AppLinagoraEcosystem> listMobileAppLinagora = linagoraEcosystem.listAppLinagoraEcosystem;
if (PlatformInfo.isAndroid) {
listMobileAppLinagora = linagoraEcosystem.listAppLinagoraEcosystemOnAndroid;
} else if (PlatformInfo.isIOS) {
listMobileAppLinagora = linagoraEcosystem.listAppLinagoraEcosystemOnIOS;
}
yield Right(GetAppGridLinagraEcosystemSuccess(listMobileAppLinagora));
} catch (e) {
yield Left(GetAppGridLinagraEcosystemFailure(e));
}
Expand Down

0 comments on commit c20e13b

Please sign in to comment.