feat: add copy link to service page

This commit is contained in:
dettlaff 2024-02-28 23:05:31 +04:00
parent c8577b3bdf
commit b537eb582d

View file

@ -2,6 +2,7 @@ import 'package:auto_route/auto_route.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:selfprivacy/config/get_it_config.dart';
import 'package:selfprivacy/logic/bloc/services/services_bloc.dart'; import 'package:selfprivacy/logic/bloc/services/services_bloc.dart';
import 'package:selfprivacy/logic/bloc/volumes/volumes_bloc.dart'; import 'package:selfprivacy/logic/bloc/volumes/volumes_bloc.dart';
import 'package:selfprivacy/logic/cubit/client_jobs/client_jobs_cubit.dart'; import 'package:selfprivacy/logic/cubit/client_jobs/client_jobs_cubit.dart';
@ -11,6 +12,7 @@ import 'package:selfprivacy/ui/components/cards/filled_card.dart';
import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
import 'package:selfprivacy/ui/router/router.dart'; import 'package:selfprivacy/ui/router/router.dart';
import 'package:selfprivacy/utils/launch_url.dart'; import 'package:selfprivacy/utils/launch_url.dart';
import 'package:selfprivacy/utils/platform_adapter.dart';
@RoutePage() @RoutePage()
class ServicePage extends StatefulWidget { class ServicePage extends StatefulWidget {
@ -62,17 +64,30 @@ class _ServicePageState extends State<ServicePage> {
ServiceStatusCard(status: service.status), ServiceStatusCard(status: service.status),
const SizedBox(height: 16), const SizedBox(height: 16),
if (service.url != null) if (service.url != null)
ListTile( GestureDetector(
iconColor: Theme.of(context).colorScheme.onBackground, onLongPress: () {
onTap: () => launchURL(service.url), PlatformAdapter.setClipboard(service.url!);
leading: const Icon(Icons.open_in_browser), getIt<NavigationService>()
title: Text( .showSnackBar('basis.copied_to_clipboard'.tr());
'service_page.open_in_browser'.tr(), },
style: Theme.of(context).textTheme.titleMedium, onSecondaryTap: () {
), PlatformAdapter.setClipboard(service.url!);
subtitle: Text( getIt<NavigationService>().showSnackBar(
service.url!.replaceAll('https://', ''), 'basis.copied_to_clipboard'.tr(),
style: Theme.of(context).textTheme.bodyMedium, );
},
child: ListTile(
iconColor: Theme.of(context).colorScheme.onBackground,
onTap: () => launchURL(service.url),
leading: const Icon(Icons.open_in_browser),
title: Text(
'service_page.open_in_browser'.tr(),
style: Theme.of(context).textTheme.titleMedium,
),
subtitle: Text(
service.url!.replaceAll('https://', ''),
style: Theme.of(context).textTheme.bodyMedium,
),
), ),
), ),
const SizedBox(height: 8), const SizedBox(height: 8),