2020-12-01 19:08:19 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:selfprivacy/config/brand_theme.dart';
|
|
|
|
import 'package:selfprivacy/logic/cubit/services/services_cubit.dart';
|
|
|
|
import 'package:selfprivacy/logic/models/service.dart';
|
|
|
|
import 'package:selfprivacy/ui/components/brand_button/brand_button.dart';
|
|
|
|
import 'package:selfprivacy/ui/components/brand_card/brand_card.dart';
|
2020-12-03 16:52:53 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_header/brand_header.dart';
|
2020-12-01 19:08:19 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_icons/brand_icons.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';
|
|
|
|
|
|
|
|
class ServicesPage extends StatefulWidget {
|
|
|
|
ServicesPage({Key key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_ServicesPageState createState() => _ServicesPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ServicesPageState extends State<ServicesPage> {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final serviceCubit = context.watch<ServicesCubit>();
|
|
|
|
final connected = serviceCubit.state.connected;
|
|
|
|
final uninitialized = serviceCubit.state.uninitialized;
|
|
|
|
return Scaffold(
|
2020-12-03 16:52:53 +00:00
|
|
|
appBar: PreferredSize(
|
|
|
|
child: BrandHeader(title: 'Сервисы'),
|
|
|
|
preferredSize: Size.fromHeight(52),
|
|
|
|
),
|
2020-12-01 19:08:19 +00:00
|
|
|
body: ListView(
|
2020-12-03 16:52:53 +00:00
|
|
|
padding: brandPagePadding2,
|
2020-12-01 19:08:19 +00:00
|
|
|
children: [
|
|
|
|
SizedBox(height: 24),
|
|
|
|
...connected.map((service) => _Card(service: service)).toList(),
|
|
|
|
if (uninitialized.isNotEmpty) ...[
|
2020-12-08 19:26:51 +00:00
|
|
|
BrandText.body1('не подключены'),
|
2020-12-01 19:08:19 +00:00
|
|
|
SizedBox(height: 30),
|
|
|
|
],
|
|
|
|
...uninitialized.map((service) => _Card(service: service)).toList()
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _Card extends StatelessWidget {
|
|
|
|
const _Card({Key key, @required this.service}) : super(key: key);
|
|
|
|
|
|
|
|
final Service service;
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
String title;
|
|
|
|
IconData iconData;
|
|
|
|
String description;
|
|
|
|
|
|
|
|
switch (service.type) {
|
|
|
|
case ServiceTypes.messanger:
|
|
|
|
iconData = BrandIcons.messanger;
|
|
|
|
title = 'Мессенджер';
|
|
|
|
description =
|
|
|
|
'Delta Chat срфеТекст-текст описание. Если бы мне надо было обсудить что-то от чего зависит жизнь. Я бы выбрал Delta.Chat + свой почтовый сервер.';
|
|
|
|
break;
|
|
|
|
case ServiceTypes.mail:
|
|
|
|
iconData = BrandIcons.envelope;
|
|
|
|
title = 'Почта';
|
|
|
|
description = 'Электронная почта для семьи или компании ';
|
|
|
|
break;
|
|
|
|
case ServiceTypes.passwordManager:
|
|
|
|
iconData = BrandIcons.key;
|
|
|
|
title = 'Менеджер паролей';
|
|
|
|
description = 'Надёжное хранилище для ваших паролей и ключей доступа';
|
|
|
|
break;
|
|
|
|
case ServiceTypes.github:
|
|
|
|
iconData = BrandIcons.github;
|
|
|
|
title = 'Git сервер';
|
|
|
|
description = 'Сервис для приватного хранения своих разработок';
|
|
|
|
break;
|
2020-12-06 07:28:31 +00:00
|
|
|
|
2020-12-01 19:08:19 +00:00
|
|
|
case ServiceTypes.cloud:
|
|
|
|
iconData = BrandIcons.upload;
|
|
|
|
title = 'Файловое Облако';
|
|
|
|
description = 'Сервис для доступа к вашим файлам в любой точке мира';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return BrandCard(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
IconStatusMaks(
|
|
|
|
status: service.state,
|
|
|
|
child: Icon(iconData, size: 30, color: Colors.white),
|
|
|
|
),
|
|
|
|
SizedBox(height: 10),
|
2020-12-08 19:26:51 +00:00
|
|
|
BrandText.h2(title),
|
2020-12-01 19:08:19 +00:00
|
|
|
SizedBox(height: 10),
|
2020-12-10 20:33:19 +00:00
|
|
|
if (service.state == StateType.uninitialized) ...[
|
2020-12-08 19:26:51 +00:00
|
|
|
BrandText.body1(description),
|
2020-12-01 19:08:19 +00:00
|
|
|
SizedBox(height: 10),
|
|
|
|
BrandButton.text(
|
|
|
|
title: 'Подключить',
|
|
|
|
onPressed: () {
|
|
|
|
context.read<ServicesCubit>().connect(service);
|
|
|
|
})
|
|
|
|
],
|
2020-12-10 20:33:19 +00:00
|
|
|
if (service.state == StateType.stable)
|
2020-12-08 19:26:51 +00:00
|
|
|
BrandText.body2('Подключен'),
|
2020-12-01 19:08:19 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|