Skip to content

Commit

Permalink
Merge pull request #22 from peercoin/v0.1.8
Browse files Browse the repository at this point in the history
v0.1.8
  • Loading branch information
Willy authored Mar 31, 2021
2 parents 542db8a + 1229611 commit e52702a
Show file tree
Hide file tree
Showing 24 changed files with 431 additions and 180 deletions.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@
android:value="2" />
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest>
8 changes: 7 additions & 1 deletion assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,15 @@
"authenticate_confirm_title" : "Re-enter your PIN",
"authenticate_confirm_title_new" : "Re-enter your new PIN",
"authenticate_change_pin_success" : "PIN succesfully changed",
"authenticate_retry_warning_title" : "Warning, you only have one retry left.",
"authenticate_retry_warning_text" : "App will go into locked state and can only be unlocked with successful authentification.",
"wallet_scan_appBar_title": "Scanning your imported seed",
"wallet_scan_notice": "This might take a while. Don't close this screen!",
"wallet_bottom_nav_receive": "Receive",
"wallet_bottom_nav_tx": "Transactions",
"wallet_bottom_nav_send": "Send"
"wallet_bottom_nav_send": "Send",
"jail_dialog_title": "You have reached the maximum number of retries.",
"jail_dialog_button": "Okay",
"jail_heading": "App locked for",
"jail_countdown": "seconds"
}
24 changes: 18 additions & 6 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 51;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -68,7 +68,6 @@
ED4CADE64C27C96F907F92DB /* Pods-Runner.release.xcconfig */,
3B99E7FFF63AD86E749DBEB7 /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
Expand Down Expand Up @@ -356,13 +355,17 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = JZZYH6WLB5;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
Expand Down Expand Up @@ -475,7 +478,8 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -488,13 +492,17 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = JZZYH6WLB5;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
Expand All @@ -515,13 +523,17 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = JZZYH6WLB5;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
Expand Down
21 changes: 18 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:peercoin/models/app_options.dart';
import 'package:peercoin/providers/appsettings.dart';
import 'package:peercoin/screens/auth_jail.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';

Expand All @@ -23,6 +25,7 @@ import 'tools/app_routes.dart';
import 'tools/app_themes.dart';

bool setupFinished;
Widget _homeWidget;

void main() async {
//init sharedpreferences
Expand Down Expand Up @@ -67,11 +70,23 @@ void main() async {
}
});

//check if app is locked
FlutterSecureStorage _secureStorage = const FlutterSecureStorage();
final failedAuths =
int.parse(await _secureStorage.read(key: "failedAuths") ?? "0");
if (setupFinished == false) {
_homeWidget = SetupScreen();
} else if (failedAuths > 0) {
_homeWidget = AuthJailScreen(true);
} else {
_homeWidget = WalletListScreen();
}

//run
runApp(MyApp());
runApp(PeercoinApp());
}

class MyApp extends StatelessWidget {
class PeercoinApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MultiProvider(
Expand Down Expand Up @@ -115,7 +130,7 @@ class MyApp extends StatelessWidget {
themeMode: ThemeMode.system, // Default
theme: MyTheme.getTheme(ThemeMode.light),
darkTheme: MyTheme.getTheme(ThemeMode.dark),
home: setupFinished ? WalletListScreen() : SetupScreen(),
home: _homeWidget,
routes: Routes.getRoutes(),
),
);
Expand Down
19 changes: 19 additions & 0 deletions lib/providers/encryptedbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class EncryptedBox with ChangeNotifier {
Map<String, Box> _cryptoBox = {};
Uint8List _encryptionKey;
String _passCode;
int _failedAuths = 0;
FlutterSecureStorage _secureStorage = const FlutterSecureStorage();

Future<Uint8List> get key async {
Expand Down Expand Up @@ -37,6 +38,24 @@ class EncryptedBox with ChangeNotifier {
return true;
}

Future<int> get failedAuths async {
if (_failedAuths == 0) {
final result = await _secureStorage.read(key: "failedAuths");
if (result == null) {
_failedAuths = 0;
} else {
_failedAuths = int.parse(result);
}
}
return _failedAuths;
}

Future<void> setFailedAuths(int newInt) async {
await _secureStorage.write(key: "failedAuths", value: newInt.toString());
_failedAuths = newInt;
return true;
}

Future<Box> getGenericBox(String name) async {
_cryptoBox[name] = await Hive.openBox(
name,
Expand Down
40 changes: 17 additions & 23 deletions lib/screens/app_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,18 @@ class _AppSettingsScreenState extends State<AppSettingsScreen> {
child: Column(
children: [
Text(
AppLocalizations.instance.translate('app_settings_auth_header'),
style: TextStyle(fontWeight: FontWeight.bold),
),
AppLocalizations.instance
.translate('app_settings_auth_header'),
style: Theme.of(context).textTheme.headline6),
SizedBox(height: 10),
_biometricsRevealed == false
? TextButton(
? ElevatedButton(
onPressed: () =>
revealAuthOptions(_settings.biometricsAllowed),
child: Text(
AppLocalizations.instance
.translate('app_settings_revealAuthButton'),
style:
TextStyle(color: Theme.of(context).primaryColor)))
AppLocalizations.instance
.translate('app_settings_revealAuthButton'),
))
: Column(children: [
SwitchListTile(
title: Text(
Expand Down Expand Up @@ -175,44 +174,39 @@ class _AppSettingsScreenState extends State<AppSettingsScreen> {
_settings.setAuthenticationOptions(
"newWallet", newState);
}),
TextButton(
ElevatedButton(
onPressed: () => changePIN(_settings.biometricsAllowed),
child: Text(
AppLocalizations.instance
.translate('app_settings_changeCode'),
style:
TextStyle(color: Theme.of(context).primaryColor),
),
)
]),
Divider(),
SizedBox(height: 10),
Text(
AppLocalizations.instance.translate('app_settings_seed'),
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(AppLocalizations.instance.translate('app_settings_seed'),
style: Theme.of(context).textTheme.headline6),
SizedBox(height: 10),
_seedPhrase == ""
? TextButton(
? ElevatedButton(
onPressed: () =>
revealSeedPhrase(_settings.biometricsAllowed),
child: Text(
AppLocalizations.instance
.translate('app_settings_revealSeedButton'),
style:
TextStyle(color: Theme.of(context).primaryColor)))
AppLocalizations.instance
.translate('app_settings_revealSeedButton'),
))
: Column(children: [
SizedBox(height: 20),
SelectableText(
_seedPhrase,
textAlign: TextAlign.center,
),
TextButton(
SizedBox(height: 20),
ElevatedButton(
onPressed: () => Share.share(_seedPhrase),
child: Text(
AppLocalizations.instance
.translate('app_settings_shareSeed'),
style:
TextStyle(color: Theme.of(context).primaryColor),
),
)
])
Expand Down
Loading

0 comments on commit e52702a

Please sign in to comment.