2020-12-02 09:16:23 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2021-09-02 19:32:07 +00:00
|
|
|
import 'package:ionicons/ionicons.dart';
|
2020-12-02 09:16:23 +00:00
|
|
|
import 'package:selfprivacy/config/brand_colors.dart';
|
|
|
|
import 'package:selfprivacy/config/brand_theme.dart';
|
2021-09-02 19:32:07 +00:00
|
|
|
import 'package:selfprivacy/config/text_themes.dart';
|
|
|
|
import 'package:selfprivacy/logic/cubit/jobs/jobs_cubit.dart';
|
|
|
|
import 'package:selfprivacy/logic/models/job.dart';
|
|
|
|
import 'package:selfprivacy/logic/models/state_types.dart';
|
|
|
|
import 'package:selfprivacy/ui/components/brand_button/brand_button.dart';
|
2020-12-02 09:16:23 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_divider/brand_divider.dart';
|
|
|
|
import 'package:selfprivacy/ui/components/brand_header/brand_header.dart';
|
|
|
|
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';
|
2021-09-02 19:32:07 +00:00
|
|
|
import 'package:selfprivacy/ui/components/icon_status_mask/icon_status_mask.dart';
|
2020-12-30 14:13:25 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/initializing/initializing.dart';
|
2021-01-06 17:35:57 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/onboarding/onboarding.dart';
|
|
|
|
import 'package:selfprivacy/ui/pages/rootRoute.dart';
|
2020-12-02 09:16:23 +00:00
|
|
|
import 'package:selfprivacy/utils/route_transitions/basic.dart';
|
2021-03-15 15:39:44 +00:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2020-12-02 09:16:23 +00:00
|
|
|
|
2020-12-06 07:46:12 +00:00
|
|
|
import 'about/about.dart';
|
|
|
|
import 'app_settings/app_setting.dart';
|
2021-01-14 21:48:05 +00:00
|
|
|
import 'console/console.dart';
|
2020-12-06 07:46:12 +00:00
|
|
|
import 'info/info.dart';
|
|
|
|
|
2020-12-02 09:16:23 +00:00
|
|
|
class MorePage extends StatelessWidget {
|
2021-03-15 15:39:44 +00:00
|
|
|
const MorePage({Key? key}) : super(key: key);
|
2020-12-02 09:16:23 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-09-02 19:32:07 +00:00
|
|
|
var jobsCubit = context.watch<JobsCubit>();
|
|
|
|
|
2020-12-03 16:52:53 +00:00
|
|
|
return Scaffold(
|
|
|
|
appBar: PreferredSize(
|
2021-09-02 19:32:07 +00:00
|
|
|
child: BrandHeader(
|
|
|
|
title: 'basis.more'.tr(),
|
|
|
|
hasFlashButton: true,
|
|
|
|
),
|
2020-12-03 16:52:53 +00:00
|
|
|
preferredSize: Size.fromHeight(52),
|
|
|
|
),
|
|
|
|
body: ListView(
|
|
|
|
children: [
|
|
|
|
Padding(
|
2021-05-25 21:53:54 +00:00
|
|
|
padding: paddingH15V0,
|
2020-12-03 16:52:53 +00:00
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
BrandDivider(),
|
2020-12-30 14:13:25 +00:00
|
|
|
_NavItem(
|
2021-03-15 15:39:44 +00:00
|
|
|
title: 'more.configuration_wizard'.tr(),
|
2021-03-18 07:26:54 +00:00
|
|
|
iconData: BrandIcons.triangle,
|
2020-12-30 14:13:25 +00:00
|
|
|
goTo: InitializingPage(),
|
|
|
|
),
|
2020-12-03 16:52:53 +00:00
|
|
|
_NavItem(
|
2021-03-25 08:32:00 +00:00
|
|
|
title: 'more.settings.title'.tr(),
|
2020-12-03 16:52:53 +00:00
|
|
|
iconData: BrandIcons.settings,
|
2020-12-06 07:46:12 +00:00
|
|
|
goTo: AppSettingsPage(),
|
2020-12-03 16:52:53 +00:00
|
|
|
),
|
|
|
|
_NavItem(
|
2021-03-15 15:39:44 +00:00
|
|
|
title: 'more.about_project'.tr(),
|
2021-03-18 07:26:54 +00:00
|
|
|
iconData: BrandIcons.engineer,
|
2020-12-03 16:52:53 +00:00
|
|
|
goTo: AboutPage(),
|
|
|
|
),
|
|
|
|
_NavItem(
|
2021-03-15 15:39:44 +00:00
|
|
|
title: 'more.about_app'.tr(),
|
2021-03-18 07:26:54 +00:00
|
|
|
iconData: BrandIcons.fire,
|
2020-12-03 16:52:53 +00:00
|
|
|
goTo: InfoPage(),
|
|
|
|
),
|
2021-01-06 17:35:57 +00:00
|
|
|
_NavItem(
|
2021-03-15 15:39:44 +00:00
|
|
|
title: 'more.onboarding'.tr(),
|
2021-03-18 07:26:54 +00:00
|
|
|
iconData: BrandIcons.start,
|
2021-01-06 17:35:57 +00:00
|
|
|
goTo: OnboardingPage(nextPage: RootPage()),
|
|
|
|
),
|
2021-01-14 21:48:05 +00:00
|
|
|
_NavItem(
|
2021-03-15 15:39:44 +00:00
|
|
|
title: 'more.console'.tr(),
|
2021-03-18 07:26:54 +00:00
|
|
|
iconData: BrandIcons.terminal,
|
2021-01-14 21:48:05 +00:00
|
|
|
goTo: Console(),
|
|
|
|
),
|
2021-09-02 19:32:07 +00:00
|
|
|
_MoreMenuTapItem(
|
|
|
|
title: 'more.create_ssh_key'.tr(),
|
|
|
|
iconData: Ionicons.key_outline,
|
|
|
|
onTap: () {
|
|
|
|
showDialog<void>(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return _MoreDetails(
|
|
|
|
title: 'more.create_ssh_key'.tr(),
|
|
|
|
icon: Ionicons.key_outline,
|
|
|
|
onTap: () {
|
|
|
|
jobsCubit.createShhJobIfNotExist(CreateSSHKeyJob());
|
|
|
|
},
|
|
|
|
text: 'more.generate_key_text'.tr(),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2020-12-03 16:52:53 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2020-12-02 09:16:23 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-02 19:32:07 +00:00
|
|
|
class _MoreDetails extends StatelessWidget {
|
|
|
|
const _MoreDetails({
|
|
|
|
Key? key,
|
|
|
|
required this.icon,
|
|
|
|
required this.title,
|
|
|
|
required this.onTap,
|
|
|
|
required this.text,
|
|
|
|
}) : super(key: key);
|
|
|
|
final String title;
|
|
|
|
final IconData icon;
|
|
|
|
final Function onTap;
|
|
|
|
final String text;
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
var textStyle = body1Style.copyWith(
|
|
|
|
color: Theme.of(context).brightness == Brightness.dark
|
|
|
|
? Colors.white
|
|
|
|
: BrandColors.black);
|
|
|
|
return Dialog(
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
),
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Container(
|
|
|
|
width: 350,
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: paddingH15V30,
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
IconStatusMask(
|
|
|
|
status: StateType.stable,
|
|
|
|
child: Icon(icon, size: 40, color: Colors.white),
|
|
|
|
),
|
|
|
|
SizedBox(height: 10),
|
|
|
|
BrandText.h2(title),
|
|
|
|
SizedBox(height: 10),
|
|
|
|
Text(
|
|
|
|
text,
|
|
|
|
style: textStyle,
|
|
|
|
),
|
|
|
|
SizedBox(height: 40),
|
|
|
|
Center(
|
|
|
|
child: Container(
|
|
|
|
child: BrandButton.rised(
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
onTap();
|
|
|
|
},
|
|
|
|
text: 'more.generate_key'.tr(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-02 09:16:23 +00:00
|
|
|
class _NavItem extends StatelessWidget {
|
|
|
|
const _NavItem({
|
2021-03-15 15:39:44 +00:00
|
|
|
Key? key,
|
|
|
|
required this.iconData,
|
|
|
|
required this.goTo,
|
|
|
|
required this.title,
|
2020-12-02 09:16:23 +00:00
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final IconData iconData;
|
|
|
|
final Widget goTo;
|
|
|
|
final String title;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: () => Navigator.of(context).push(materialRoute(goTo)),
|
2021-09-02 19:32:07 +00:00
|
|
|
child: _MoreMenuItem(
|
|
|
|
iconData: iconData,
|
|
|
|
title: title,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MoreMenuTapItem extends StatelessWidget {
|
|
|
|
const _MoreMenuTapItem({
|
|
|
|
Key? key,
|
|
|
|
required this.iconData,
|
|
|
|
required this.onTap,
|
|
|
|
required this.title,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final IconData iconData;
|
|
|
|
final Function onTap;
|
|
|
|
final String title;
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
onTap();
|
|
|
|
},
|
|
|
|
child: _MoreMenuItem(
|
|
|
|
iconData: iconData,
|
|
|
|
title: title,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MoreMenuItem extends StatelessWidget {
|
|
|
|
const _MoreMenuItem({
|
|
|
|
Key? key,
|
|
|
|
required this.iconData,
|
|
|
|
required this.title,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final IconData iconData;
|
|
|
|
final String title;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 24),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
bottom: BorderSide(
|
|
|
|
width: 1.0,
|
|
|
|
color: BrandColors.dividerColor,
|
2020-12-02 09:16:23 +00:00
|
|
|
),
|
|
|
|
),
|
2021-09-02 19:32:07 +00:00
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
BrandText.body1(title),
|
|
|
|
Spacer(),
|
|
|
|
SizedBox(
|
|
|
|
width: 56,
|
|
|
|
child: Icon(
|
|
|
|
iconData,
|
|
|
|
size: 20,
|
2020-12-03 16:52:53 +00:00
|
|
|
),
|
2021-09-02 19:32:07 +00:00
|
|
|
),
|
|
|
|
],
|
2020-12-02 09:16:23 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|