2020-12-01 19:08:19 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2021-03-18 00:55:38 +00:00
|
|
|
import 'package:selfprivacy/config/brand_colors.dart';
|
2020-12-01 19:08:19 +00:00
|
|
|
import 'package:selfprivacy/config/brand_theme.dart';
|
2021-03-18 00:55:38 +00:00
|
|
|
import 'package:selfprivacy/config/text_themes.dart';
|
2021-08-18 10:44:46 +00:00
|
|
|
import 'package:selfprivacy/logic/common_enum/common_enum.dart';
|
2021-01-06 17:35:57 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
2021-03-18 00:55:38 +00:00
|
|
|
import 'package:selfprivacy/logic/models/state_types.dart';
|
2021-03-26 13:38:39 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_button/brand_button.dart';
|
2021-05-25 21:53:54 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_cards/brand_cards.dart';
|
2020-12-03 16:52:53 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_header/brand_header.dart';
|
2020-12-08 19:26:51 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_text/brand_text.dart';
|
2020-12-01 19:08:19 +00:00
|
|
|
import 'package:selfprivacy/ui/components/icon_status_mask/icon_status_mask.dart';
|
2021-01-06 17:35:57 +00:00
|
|
|
import 'package:selfprivacy/ui/components/not_ready_card/not_ready_card.dart';
|
2021-03-18 00:55:38 +00:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2021-03-26 13:38:39 +00:00
|
|
|
import 'package:selfprivacy/utils/ui_helpers.dart';
|
2021-03-18 00:55:38 +00:00
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
|
|
|
|
import '../rootRoute.dart';
|
2020-12-01 19:08:19 +00:00
|
|
|
|
|
|
|
class ServicesPage extends StatefulWidget {
|
2021-03-15 15:39:44 +00:00
|
|
|
ServicesPage({Key? key}) : super(key: key);
|
2020-12-01 19:08:19 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
_ServicesPageState createState() => _ServicesPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ServicesPageState extends State<ServicesPage> {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-01-06 17:35:57 +00:00
|
|
|
var isReady = context.watch<AppConfigCubit>().state.isFullyInitilized;
|
|
|
|
|
2020-12-01 19:08:19 +00:00
|
|
|
return Scaffold(
|
2020-12-03 16:52:53 +00:00
|
|
|
appBar: PreferredSize(
|
2021-05-25 21:53:54 +00:00
|
|
|
child: BrandHeader(
|
|
|
|
title: 'basis.services'.tr(),
|
|
|
|
hasFlashButton: true,
|
|
|
|
),
|
2020-12-03 16:52:53 +00:00
|
|
|
preferredSize: Size.fromHeight(52),
|
|
|
|
),
|
2020-12-01 19:08:19 +00:00
|
|
|
body: ListView(
|
2021-05-25 21:53:54 +00:00
|
|
|
padding: paddingH15V0,
|
2020-12-01 19:08:19 +00:00
|
|
|
children: [
|
2021-03-18 00:55:38 +00:00
|
|
|
BrandText.body1('services.title'.tr()),
|
2020-12-01 19:08:19 +00:00
|
|
|
SizedBox(height: 24),
|
2021-03-18 00:55:38 +00:00
|
|
|
if (!isReady) ...[NotReadyCard(), SizedBox(height: 24)],
|
2021-03-25 08:54:39 +00:00
|
|
|
...ServiceTypes.values
|
|
|
|
.map((t) => Padding(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
bottom: 30,
|
|
|
|
),
|
|
|
|
child: _Card(serviceType: t),
|
|
|
|
))
|
|
|
|
.toList()
|
2020-12-01 19:08:19 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _Card extends StatelessWidget {
|
2021-03-18 00:55:38 +00:00
|
|
|
const _Card({Key? key, required this.serviceType}) : super(key: key);
|
2020-12-01 19:08:19 +00:00
|
|
|
|
2021-03-18 00:55:38 +00:00
|
|
|
final ServiceTypes serviceType;
|
2020-12-01 19:08:19 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-03-18 00:55:38 +00:00
|
|
|
var isReady = context.watch<AppConfigCubit>().state.isFullyInitilized;
|
|
|
|
var changeTab = context.read<ChangeTab>().onPress;
|
|
|
|
return GestureDetector(
|
2021-06-08 18:52:44 +00:00
|
|
|
onTap: isReady
|
|
|
|
? () => showDialog<void>(
|
|
|
|
context: context,
|
|
|
|
// isScrollControlled: true,
|
|
|
|
// backgroundColor: Colors.transparent,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return _ServiceDetails(
|
|
|
|
serviceType: serviceType,
|
|
|
|
status:
|
|
|
|
isReady ? StateType.stable : StateType.uninitialized,
|
2021-08-18 10:44:46 +00:00
|
|
|
title: serviceType.title,
|
|
|
|
icon: serviceType.icon,
|
2021-06-08 18:52:44 +00:00
|
|
|
changeTab: changeTab,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
)
|
|
|
|
: null,
|
2021-05-25 21:53:54 +00:00
|
|
|
child: BrandCards.big(
|
2021-03-18 00:55:38 +00:00
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
IconStatusMask(
|
|
|
|
status: isReady ? StateType.stable : StateType.uninitialized,
|
2021-08-18 10:44:46 +00:00
|
|
|
child: Icon(serviceType.icon, size: 30, color: Colors.white),
|
2021-03-18 00:55:38 +00:00
|
|
|
),
|
|
|
|
SizedBox(height: 10),
|
2021-08-18 10:44:46 +00:00
|
|
|
BrandText.h2(serviceType.title),
|
2021-03-18 00:55:38 +00:00
|
|
|
SizedBox(height: 10),
|
2021-08-18 10:44:46 +00:00
|
|
|
BrandText.body2(serviceType.subtitle),
|
2020-12-01 19:08:19 +00:00
|
|
|
SizedBox(height: 10),
|
|
|
|
],
|
2021-03-18 00:55:38 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ServiceDetails extends StatelessWidget {
|
|
|
|
const _ServiceDetails({
|
|
|
|
Key? key,
|
|
|
|
required this.serviceType,
|
|
|
|
required this.icon,
|
|
|
|
required this.status,
|
|
|
|
required this.title,
|
|
|
|
required this.changeTab,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final ServiceTypes serviceType;
|
|
|
|
final IconData icon;
|
|
|
|
final StateType status;
|
|
|
|
final String title;
|
|
|
|
final ValueChanged<int> changeTab;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
late Widget child;
|
|
|
|
|
|
|
|
var config = context.watch<AppConfigCubit>().state;
|
2021-03-26 13:38:39 +00:00
|
|
|
var domainName = UiHelpers.getDomainName(config);
|
2021-03-18 00:55:38 +00:00
|
|
|
|
|
|
|
var linksStyle = body1Style.copyWith(
|
|
|
|
fontSize: 15,
|
|
|
|
color: Theme.of(context).brightness == Brightness.dark
|
|
|
|
? Colors.white
|
|
|
|
: BrandColors.black,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
decoration: TextDecoration.underline,
|
|
|
|
);
|
|
|
|
|
|
|
|
var textStyle = body1Style.copyWith(
|
|
|
|
color: Theme.of(context).brightness == Brightness.dark
|
|
|
|
? Colors.white
|
|
|
|
: BrandColors.black,
|
|
|
|
);
|
|
|
|
switch (serviceType) {
|
|
|
|
case ServiceTypes.mail:
|
|
|
|
child = RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
|
|
|
text: 'services.mail.bottom_sheet.1'.tr(args: [domainName]),
|
|
|
|
style: textStyle,
|
|
|
|
),
|
2021-03-26 13:38:39 +00:00
|
|
|
WidgetSpan(child: SizedBox(width: 5)),
|
2021-03-18 00:55:38 +00:00
|
|
|
WidgetSpan(
|
|
|
|
child: Padding(
|
2021-03-26 13:38:39 +00:00
|
|
|
padding: EdgeInsets.only(bottom: 0.8),
|
2021-03-18 00:55:38 +00:00
|
|
|
child: GestureDetector(
|
|
|
|
child: Text(
|
|
|
|
'services.mail.bottom_sheet.2'.tr(),
|
|
|
|
style: linksStyle,
|
|
|
|
),
|
|
|
|
onTap: () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
changeTab(2);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
));
|
|
|
|
break;
|
|
|
|
case ServiceTypes.messenger:
|
|
|
|
child = RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
|
|
|
text: 'services.messenger.bottom_sheet.1'.tr(args: [domainName]),
|
|
|
|
style: textStyle,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
));
|
|
|
|
break;
|
|
|
|
case ServiceTypes.passwordManager:
|
|
|
|
child = RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
|
|
|
text: 'services.password_manager.bottom_sheet.1'
|
|
|
|
.tr(args: [domainName]),
|
|
|
|
style: textStyle,
|
|
|
|
),
|
2021-03-26 13:38:39 +00:00
|
|
|
WidgetSpan(child: SizedBox(width: 5)),
|
2021-03-18 00:55:38 +00:00
|
|
|
WidgetSpan(
|
|
|
|
child: Padding(
|
2021-03-26 13:38:39 +00:00
|
|
|
padding: EdgeInsets.only(bottom: 0.8),
|
2021-03-18 00:55:38 +00:00
|
|
|
child: GestureDetector(
|
|
|
|
onTap: () => _launchURL('https://password.$domainName'),
|
|
|
|
child: Text(
|
|
|
|
'password.$domainName',
|
|
|
|
style: linksStyle,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
));
|
|
|
|
break;
|
|
|
|
case ServiceTypes.video:
|
|
|
|
child = RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
|
|
|
text: 'services.video.bottom_sheet.1'.tr(args: [domainName]),
|
|
|
|
style: textStyle,
|
|
|
|
),
|
2021-03-26 13:38:39 +00:00
|
|
|
WidgetSpan(child: SizedBox(width: 5)),
|
2021-03-18 00:55:38 +00:00
|
|
|
WidgetSpan(
|
|
|
|
child: Padding(
|
2021-03-26 13:38:39 +00:00
|
|
|
padding: EdgeInsets.only(bottom: 0.8),
|
2021-03-18 00:55:38 +00:00
|
|
|
child: GestureDetector(
|
|
|
|
onTap: () => _launchURL('https://meet.$domainName'),
|
|
|
|
child: Text(
|
|
|
|
'meet.$domainName',
|
|
|
|
style: linksStyle,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
));
|
|
|
|
break;
|
|
|
|
case ServiceTypes.cloud:
|
|
|
|
child = RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
|
|
|
text: 'services.cloud.bottom_sheet.1'.tr(args: [domainName]),
|
|
|
|
style: textStyle,
|
|
|
|
),
|
2021-03-26 13:38:39 +00:00
|
|
|
WidgetSpan(child: SizedBox(width: 5)),
|
2021-03-18 00:55:38 +00:00
|
|
|
WidgetSpan(
|
|
|
|
child: Padding(
|
2021-03-26 13:38:39 +00:00
|
|
|
padding: EdgeInsets.only(bottom: 0.8),
|
2021-03-18 00:55:38 +00:00
|
|
|
child: GestureDetector(
|
|
|
|
onTap: () => _launchURL('https://cloud.$domainName'),
|
|
|
|
child: Text(
|
|
|
|
'cloud.$domainName',
|
|
|
|
style: linksStyle,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
));
|
|
|
|
break;
|
|
|
|
case ServiceTypes.socialNetwork:
|
|
|
|
child = RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
|
|
|
text: 'services.social_network.bottom_sheet.1'
|
|
|
|
.tr(args: [domainName]),
|
|
|
|
style: textStyle,
|
|
|
|
),
|
2021-03-26 13:38:39 +00:00
|
|
|
WidgetSpan(child: SizedBox(width: 5)),
|
2021-03-18 00:55:38 +00:00
|
|
|
WidgetSpan(
|
|
|
|
child: Padding(
|
2021-03-26 13:38:39 +00:00
|
|
|
padding: EdgeInsets.only(bottom: 0.8),
|
2021-03-18 00:55:38 +00:00
|
|
|
child: GestureDetector(
|
2021-03-24 13:12:09 +00:00
|
|
|
onTap: () => _launchURL('https://social.$domainName'),
|
2021-03-18 00:55:38 +00:00
|
|
|
child: Text(
|
|
|
|
'social.$domainName',
|
|
|
|
style: linksStyle,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
));
|
|
|
|
break;
|
|
|
|
case ServiceTypes.git:
|
|
|
|
child = RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
|
|
|
text: 'services.git.bottom_sheet.1'.tr(args: [domainName]),
|
|
|
|
style: textStyle,
|
|
|
|
),
|
2021-03-26 13:38:39 +00:00
|
|
|
WidgetSpan(child: SizedBox(width: 5)),
|
2021-03-18 00:55:38 +00:00
|
|
|
WidgetSpan(
|
|
|
|
child: Padding(
|
2021-03-26 13:38:39 +00:00
|
|
|
padding: EdgeInsets.only(bottom: 0.8),
|
2021-03-18 00:55:38 +00:00
|
|
|
child: GestureDetector(
|
|
|
|
onTap: () => _launchURL('https://git.$domainName'),
|
|
|
|
child: Text(
|
|
|
|
'git.$domainName',
|
|
|
|
style: linksStyle,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
));
|
|
|
|
break;
|
2021-08-29 13:54:28 +00:00
|
|
|
case ServiceTypes.vpn:
|
|
|
|
child = Text(
|
|
|
|
'services.vpn.bottom_sheet.1'.tr(),
|
|
|
|
);
|
2021-03-18 00:55:38 +00:00
|
|
|
}
|
2021-03-26 13:38:39 +00:00
|
|
|
return Dialog(
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
),
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Container(
|
|
|
|
width: 350,
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Padding(
|
2021-05-25 21:53:54 +00:00
|
|
|
padding: paddingH15V30,
|
2021-03-26 13:38:39 +00:00
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
IconStatusMask(
|
|
|
|
status: status,
|
|
|
|
child: Icon(icon, size: 40, color: Colors.white),
|
|
|
|
),
|
|
|
|
SizedBox(height: 10),
|
|
|
|
BrandText.h2(title),
|
|
|
|
SizedBox(height: 10),
|
|
|
|
child,
|
|
|
|
SizedBox(height: 40),
|
|
|
|
Center(
|
|
|
|
child: Container(
|
|
|
|
child: BrandButton.rised(
|
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
2021-05-25 21:53:54 +00:00
|
|
|
text: 'basis.close'.tr(),
|
2021-03-26 13:38:39 +00:00
|
|
|
),
|
2021-03-18 00:55:38 +00:00
|
|
|
),
|
2021-03-26 13:38:39 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2020-12-01 19:08:19 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2021-03-18 00:55:38 +00:00
|
|
|
|
2021-03-25 20:09:56 +00:00
|
|
|
void _launchURL(url) async {
|
|
|
|
var _possible = await canLaunch(url);
|
|
|
|
|
|
|
|
if (_possible) {
|
|
|
|
try {
|
|
|
|
await launch(
|
|
|
|
url,
|
|
|
|
enableJavaScript: true,
|
|
|
|
);
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
throw 'Could not launch $url';
|
|
|
|
}
|
|
|
|
}
|
2020-12-01 19:08:19 +00:00
|
|
|
}
|