2020-12-06 07:46:12 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:selfprivacy/config/brand_colors.dart';
|
|
|
|
import 'package:selfprivacy/config/brand_theme.dart';
|
2020-12-08 19:26:51 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/app_settings/app_settings_cubit.dart';
|
2021-01-06 17:35:57 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
2021-02-15 18:58:29 +00:00
|
|
|
import 'package:selfprivacy/ui/components/action_button/action_button.dart';
|
|
|
|
import 'package:selfprivacy/ui/components/brand_alert/brand_alert.dart';
|
2020-12-06 07:46:12 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_divider/brand_divider.dart';
|
|
|
|
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';
|
2021-01-06 17:35:57 +00:00
|
|
|
import 'package:selfprivacy/utils/named_font_weight.dart';
|
2020-12-06 07:46:12 +00:00
|
|
|
|
2020-12-08 19:26:51 +00:00
|
|
|
class AppSettingsPage extends StatefulWidget {
|
2020-12-06 07:46:12 +00:00
|
|
|
const AppSettingsPage({Key key}) : super(key: key);
|
|
|
|
|
2020-12-08 19:26:51 +00:00
|
|
|
@override
|
|
|
|
_AppSettingsPageState createState() => _AppSettingsPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _AppSettingsPageState extends State<AppSettingsPage> {
|
2020-12-06 07:46:12 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-12-08 19:26:51 +00:00
|
|
|
var appSettings = context.watch<AppSettingsCubit>();
|
|
|
|
|
|
|
|
var isDarkModeOn = appSettings.state.isDarkModeOn;
|
|
|
|
|
2020-12-06 07:46:12 +00:00
|
|
|
return SafeArea(
|
2020-12-08 19:26:51 +00:00
|
|
|
child: Builder(builder: (context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: PreferredSize(
|
|
|
|
child:
|
|
|
|
BrandHeader(title: 'Настройки приложения', hasBackButton: true),
|
|
|
|
preferredSize: Size.fromHeight(52),
|
|
|
|
),
|
|
|
|
body: ListView(
|
|
|
|
padding: brandPagePadding2,
|
|
|
|
children: [
|
|
|
|
BrandDivider(),
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.only(top: 20, bottom: 5),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
bottom: BorderSide(width: 1, color: BrandColors.dividerColor),
|
|
|
|
)),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Flexible(
|
|
|
|
child: _TextColumn(
|
|
|
|
title: 'Dark Theme',
|
|
|
|
value: 'Change your the app theme',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(width: 5),
|
|
|
|
Switch(
|
|
|
|
activeColor: BrandColors.green1,
|
|
|
|
activeTrackColor: BrandColors.green2,
|
|
|
|
value: Theme.of(context).brightness == Brightness.dark,
|
2021-01-06 17:35:57 +00:00
|
|
|
onChanged: (value) => appSettings.updateDarkMode(
|
|
|
|
isDarkModeOn: !isDarkModeOn),
|
2020-12-08 19:26:51 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2021-01-06 17:35:57 +00:00
|
|
|
),
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.only(top: 20, bottom: 5),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
bottom: BorderSide(width: 1, color: BrandColors.dividerColor),
|
|
|
|
)),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Flexible(
|
|
|
|
child: _TextColumn(
|
|
|
|
title: 'Reset app config',
|
|
|
|
value: 'Reset api keys and root user',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(width: 5),
|
2021-03-14 18:44:35 +00:00
|
|
|
ElevatedButton(
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
primary: BrandColors.red1,
|
|
|
|
),
|
2021-01-06 17:35:57 +00:00
|
|
|
child: Text(
|
|
|
|
'Reset',
|
|
|
|
style: TextStyle(
|
|
|
|
color: BrandColors.white,
|
|
|
|
fontWeight: NamedFontWeight.demiBold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
showDialog(
|
2021-02-15 18:58:29 +00:00
|
|
|
context: context,
|
2021-03-14 18:44:35 +00:00
|
|
|
builder: (_) {
|
|
|
|
return BrandAlert(
|
|
|
|
title: 'Вы уверенны',
|
|
|
|
contentText: 'Сбросить все ключи?',
|
|
|
|
acitons: [
|
|
|
|
ActionButton(
|
|
|
|
text: 'Да, сбросить',
|
|
|
|
isRed: true,
|
|
|
|
onPressed: () {
|
|
|
|
context
|
|
|
|
.read<AppConfigCubit>()
|
|
|
|
.clearAppConfig();
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
}),
|
|
|
|
ActionButton(
|
|
|
|
text: 'Отмена',
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
2021-02-15 18:58:29 +00:00
|
|
|
);
|
2021-01-06 17:35:57 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2020-12-08 19:26:51 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}),
|
2020-12-06 07:46:12 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _TextColumn extends StatelessWidget {
|
|
|
|
const _TextColumn({
|
|
|
|
Key key,
|
|
|
|
@required this.title,
|
|
|
|
@required this.value,
|
|
|
|
this.hasWarning = false,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final String title;
|
|
|
|
final String value;
|
|
|
|
final bool hasWarning;
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2020-12-08 19:26:51 +00:00
|
|
|
BrandText.body1(
|
|
|
|
title,
|
|
|
|
style: TextStyle(color: hasWarning ? BrandColors.warning : null),
|
|
|
|
),
|
2020-12-06 07:46:12 +00:00
|
|
|
SizedBox(height: 5),
|
2020-12-08 19:26:51 +00:00
|
|
|
BrandText.body1(value,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 13,
|
|
|
|
height: 1.53,
|
|
|
|
color: BrandColors.gray1,
|
|
|
|
).merge(TextStyle(color: hasWarning ? BrandColors.warning : null))),
|
2020-12-06 07:46:12 +00:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|