mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-15 07:56:11 +08:00

The accounts setup is taking way way too long. And some ios users have paid for pro and haven't gotten it. This way, they will at least get it ASAP. I should have done this weeks ago.
140 lines
4.2 KiB
Dart
140 lines
4.2 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:crypto/crypto.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:gitjournal/app_settings.dart';
|
|
import 'package:gitjournal/features.dart';
|
|
|
|
class ExperimentalSettingsScreen extends StatefulWidget {
|
|
@override
|
|
_ExperimentalSettingsScreenState createState() =>
|
|
_ExperimentalSettingsScreenState();
|
|
}
|
|
|
|
class _ExperimentalSettingsScreenState
|
|
extends State<ExperimentalSettingsScreen> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
var appSettings = Provider.of<AppSettings>(context);
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text(tr('settings.experimental.title')),
|
|
leading: IconButton(
|
|
icon: const Icon(Icons.arrow_back),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
),
|
|
body: Scrollbar(
|
|
child: ListView(
|
|
children: <Widget>[
|
|
SwitchListTile(
|
|
title: Text(tr('settings.experimental.fs')),
|
|
value: appSettings.experimentalFs,
|
|
onChanged: (bool newVal) {
|
|
appSettings.experimentalFs = newVal;
|
|
appSettings.save();
|
|
setState(() {});
|
|
},
|
|
),
|
|
SwitchListTile(
|
|
title: Text(tr('settings.experimental.graphView')),
|
|
value: appSettings.experimentalGraphView,
|
|
onChanged: (bool newVal) {
|
|
appSettings.experimentalGraphView = newVal;
|
|
appSettings.save();
|
|
setState(() {});
|
|
},
|
|
),
|
|
SwitchListTile(
|
|
title: Text(tr('settings.experimental.markdownToolbar')),
|
|
value: appSettings.experimentalMarkdownToolbar,
|
|
onChanged: (bool newVal) {
|
|
appSettings.experimentalMarkdownToolbar = newVal;
|
|
appSettings.save();
|
|
setState(() {});
|
|
},
|
|
),
|
|
SwitchListTile(
|
|
title: Text(tr('settings.experimental.accounts')),
|
|
value: appSettings.experimentalAccounts,
|
|
onChanged: (bool newVal) {
|
|
appSettings.experimentalAccounts = newVal;
|
|
appSettings.save();
|
|
setState(() {});
|
|
},
|
|
),
|
|
ListTile(
|
|
title: const Text('Enter Pro Password'),
|
|
subtitle: Text('Pro: ' + AppSettings.instance.proMode.toString()),
|
|
onTap: () async {
|
|
await showDialog(
|
|
context: context,
|
|
builder: (context) => _PasswordForm(),
|
|
);
|
|
setState(() {});
|
|
print('Changing State');
|
|
},
|
|
),
|
|
],
|
|
padding: const EdgeInsets.fromLTRB(0.0, 16.0, 0.0, 0.0),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _PasswordForm extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AlertDialog(
|
|
title: const Text('Enter Pro Password'),
|
|
content: TextField(
|
|
style: Theme.of(context).textTheme.headline6,
|
|
decoration: const InputDecoration(
|
|
icon: Icon(Icons.security_rounded),
|
|
hintText: 'Enter Password',
|
|
labelText: 'Password',
|
|
),
|
|
onChanged: (String value) {
|
|
value = value.trim();
|
|
if (value.isEmpty) {
|
|
return null;
|
|
}
|
|
|
|
final salt = 'randomSaltGitJournal';
|
|
var sha1Digest = sha1.convert(utf8.encode(value + salt));
|
|
print(sha1Digest);
|
|
|
|
if (sha1Digest.toString() !=
|
|
'27538d8231e49655fd1c26c7b8495c2c870c741b') {
|
|
return null;
|
|
}
|
|
|
|
print('Unlocking Pro Mode');
|
|
|
|
var appSettings = AppSettings.instance;
|
|
appSettings.proMode = true;
|
|
appSettings.validateProMode = false;
|
|
appSettings.proExpirationDate = '2050-01-01';
|
|
appSettings.save();
|
|
},
|
|
),
|
|
actions: <Widget>[
|
|
FlatButton(
|
|
child: const Text('Ok'),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|