mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-11 21:12:44 +08:00
Add a workaround for giving people pro mode
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.
This commit is contained in:
@ -23,6 +23,7 @@ class AppSettings extends ChangeNotifier {
|
||||
|
||||
var proMode = Features.alwaysPro;
|
||||
var proExpirationDate = "";
|
||||
var validateProMode = true;
|
||||
|
||||
String _pseudoId;
|
||||
String get pseudoId => _pseudoId;
|
||||
@ -49,6 +50,7 @@ class AppSettings extends ChangeNotifier {
|
||||
proMode = pref.getBool("proMode") ?? proMode;
|
||||
proExpirationDate =
|
||||
pref.getString("proExpirationDate") ?? proExpirationDate;
|
||||
validateProMode = pref.getBool("validateProMode") ?? validateProMode;
|
||||
|
||||
_pseudoId = pref.getString("pseudoId");
|
||||
if (_pseudoId == null) {
|
||||
@ -84,6 +86,8 @@ class AppSettings extends ChangeNotifier {
|
||||
_setString(pref, "proExpirationDate", proExpirationDate,
|
||||
defaultSet.proExpirationDate);
|
||||
_setBool(pref, "proMode", proMode, defaultSet.proMode);
|
||||
_setBool(
|
||||
pref, "validateProMode", validateProMode, defaultSet.validateProMode);
|
||||
_setString(pref, "debugLogLevel", debugLogLevel, defaultSet.debugLogLevel);
|
||||
_setBool(pref, "experimentalFs", experimentalFs, defaultSet.experimentalFs);
|
||||
_setBool(pref, "experimentalMarkdownToolbar", experimentalMarkdownToolbar,
|
||||
@ -108,6 +112,7 @@ class AppSettings extends ChangeNotifier {
|
||||
"collectCrashReports": collectCrashReports.toString(),
|
||||
"version": version.toString(),
|
||||
"proMode": proMode.toString(),
|
||||
'validateProMode': validateProMode.toString(),
|
||||
'proExpirationDate': proExpirationDate,
|
||||
'pseudoId': pseudoId,
|
||||
'debugLogLevel': debugLogLevel,
|
||||
|
@ -17,7 +17,7 @@ class InAppPurchases {
|
||||
clearTransactionsIos();
|
||||
confirmPendingPurchases();
|
||||
|
||||
if (Features.alwaysPro) {
|
||||
if (Features.alwaysPro || !AppSettings.instance.validateProMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,13 @@
|
||||
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
|
||||
@ -66,6 +70,18 @@ class _ExperimentalSettingsScreenState
|
||||
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),
|
||||
),
|
||||
@ -73,3 +89,51 @@ class _ExperimentalSettingsScreenState
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user