TF-1665 Enable app grid on mobile
(cherry picked from commit c9f9a2c214316606c8d3f9d63cf38c326369b112)
This commit is contained in:
@@ -69,16 +69,13 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView {
|
||||
alignment: Alignment.center,
|
||||
height: 80,
|
||||
child: Row(children: [
|
||||
(SloganBuilder(arrangedByHorizontal: true)
|
||||
..setSloganText(AppLocalizations.of(context).app_name)
|
||||
..setSloganTextAlign(TextAlign.center)
|
||||
..setSloganTextStyle(const TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold))
|
||||
..setSizeLogo(24)
|
||||
..setLogo(imagePaths.icLogoTMail))
|
||||
.build(),
|
||||
SloganBuilder(
|
||||
sizeLogo: 24,
|
||||
text: AppLocalizations.of(context).app_name,
|
||||
textAlign: TextAlign.center,
|
||||
textStyle: const TextStyle(color: Colors.black, fontSize: 20, fontWeight: FontWeight.bold),
|
||||
logo: imagePaths.icLogoTMail
|
||||
),
|
||||
Obx(() {
|
||||
if (controller.appInformation.value != null) {
|
||||
return Padding(padding: const EdgeInsets.only(top: 6),
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ class AppGridDashboardItem extends StatelessWidget {
|
||||
child: InkWell(
|
||||
onTap: _openApp,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||
hoverColor: AppColor.colorItemSelected,
|
||||
hoverColor: AppColor.colorBgMailboxSelected,
|
||||
child: Container(
|
||||
width: 98,
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
|
||||
+39
-57
@@ -1,76 +1,58 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:core/presentation/views/text/slogan_builder.dart';
|
||||
import 'package:core/utils/build_utils.dart';
|
||||
import 'package:external_app_launcher/external_app_launcher.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get_core/get_core.dart';
|
||||
import 'package:get/get_instance/get_instance.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/app_dashboard/linagora_app.dart';
|
||||
import 'package:url_launcher/url_launcher.dart' as launcher;
|
||||
|
||||
class AppListDashboardItem extends StatefulWidget {
|
||||
class AppListDashboardItem extends StatelessWidget {
|
||||
|
||||
final LinagoraApp app;
|
||||
|
||||
const AppListDashboardItem(this.app, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AppListDashboardItem> createState() => _AppListDashboardItemState();
|
||||
}
|
||||
|
||||
class _AppListDashboardItemState extends State<AppListDashboardItem> {
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
bool _isHoverItem = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return InkWell(
|
||||
onTap: () => _openApp(widget.app.appUri),
|
||||
onHover: (value) => setState(() => _isHoverItem = value),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
color: _backgroundColorItem(context)),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 18),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: _buildAppItem(context)
|
||||
),
|
||||
);
|
||||
}
|
||||
final imagePaths = Get.find<ImagePaths>();
|
||||
return SloganBuilder(
|
||||
sizeLogo: 32,
|
||||
paddingText: const EdgeInsets.only(left: 12),
|
||||
text: app.appName,
|
||||
textAlign: TextAlign.center,
|
||||
textStyle: const TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: AppColor.colorNameEmail),
|
||||
logo: !app.iconName.endsWith('svg') ? imagePaths.getConfigurationImagePath(app.iconName) : null,
|
||||
logoSVG: app.iconName.endsWith('svg') ? imagePaths.getConfigurationImagePath(app.iconName) : null,
|
||||
onTapCallback: () => _openApp(context, app),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 20),
|
||||
hoverColor: AppColor.colorBgMailboxSelected
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAppItem(BuildContext context) {
|
||||
final builder = SloganBuilder(arrangedByHorizontal: true)
|
||||
..setSizeLogo(32.0)
|
||||
..setPadding(const EdgeInsets.only(left: 12))
|
||||
..setSloganText(widget.app.appName)
|
||||
..addOnTapCallback(() async {
|
||||
final url = widget.app.appUri;
|
||||
if (await launcher.canLaunchUrl(url)) {
|
||||
await launcher.launchUrl(url);
|
||||
}
|
||||
})
|
||||
..setSloganTextStyle(const TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: AppColor.colorNameEmail));
|
||||
if (widget.app.iconName.endsWith('svg')) {
|
||||
builder.setLogoSVG(_imagePaths.getConfigurationImagePath(widget.app.iconName));
|
||||
void _openApp(BuildContext context, LinagoraApp app) async {
|
||||
if (BuildUtils.isWeb) {
|
||||
if (await launcher.canLaunchUrl(app.appUri)) {
|
||||
await launcher.launchUrl(app.appUri);
|
||||
}
|
||||
} else if (Platform.isAndroid && app.androidPackageId?.isNotEmpty == true) {
|
||||
await LaunchApp.openApp(androidPackageName: app.androidPackageId);
|
||||
} else if (Platform.isIOS && app.iosUrlScheme?.isNotEmpty == true) {
|
||||
await LaunchApp.openApp(
|
||||
iosUrlScheme: '${app.iosUrlScheme}://',
|
||||
appStoreLink: app.iosAppStoreLink
|
||||
);
|
||||
} else {
|
||||
builder.setLogo(_imagePaths.getConfigurationImagePath(widget.app.iconName));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
Color _backgroundColorItem(BuildContext context) {
|
||||
if (_isHoverItem) {
|
||||
return AppColor.colorBgMailboxSelected;
|
||||
}
|
||||
return _responsiveUtils.isDesktop(context)
|
||||
? AppColor.colorBgDesktop
|
||||
: Colors.white;
|
||||
}
|
||||
|
||||
void _openApp(Uri appLink) async {
|
||||
if (await launcher.canLaunchUrl(appLink)) {
|
||||
await launcher.launchUrl(appLink);
|
||||
if (await launcher.canLaunchUrl(app.appUri)) {
|
||||
await launcher.launchUrl(
|
||||
app.appUri,
|
||||
mode: launcher.LaunchMode.externalApplication
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user