You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HMG_Patient_App_New/lib/presentation/hmg_services/services_view.dart

73 lines
2.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_export.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/hmg_services/models/ui_models/hmg_services_component_model.dart';
import 'package:hmg_patient_app_new/services/navigation_service.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:url_launcher/url_launcher.dart';
class ServiceGridViewItem extends StatelessWidget {
final HmgServicesComponentModel hmgServiceComponentModel;
final int index;
final bool isHomePage;
final bool isLocked;
final bool isHealthToolIcon;
final Function? onTap;
const ServiceGridViewItem(
this.hmgServiceComponentModel, this.index, this.isHomePage,
{super.key, this.isLocked = false, required this.isHealthToolIcon, this.onTap});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () => hmgServiceComponentModel.isExternalLink
? _openLink(hmgServiceComponentModel.route!)
: getIt
.get<NavigationService>()
.pushPageRoute(hmgServiceComponentModel.route!),
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 48.h,
width: 48.w,
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: hmgServiceComponentModel.bgColor,
borderRadius: 12.r,
hasShadow: false,
),
child: Padding(
padding: EdgeInsets.all(12.h),
child: Utils.buildSvgWithAssets(
icon: hmgServiceComponentModel.icon,
iconColor: isHealthToolIcon ? null : AppColors.whiteColor,
fit: BoxFit.contain,
),
),
),
SizedBox(height: 5.h),
hmgServiceComponentModel.title.toText12(
fontWeight: FontWeight.w500,
color: AppColors.textColor,
maxLine: 2,
),
],
));
}
Future<void> _openLink(String link) async {
final Uri url = Uri.parse(link);
if (await canLaunchUrl(url)) {
await launchUrl(url, mode: LaunchMode.externalApplication);
} else {
throw "Could not launch $url";
}
}
}