Skip to content

Commit

Permalink
update & refactor v3
Browse files Browse the repository at this point in the history
- update translations
- fix camera permission
- cleanup and remove unused code
- remove derivation path `111111`(Kaspa) support
- reduce unused address buffer size
- refactor backup secret phrase
- refactor privacy overlay
- remove unused logger
- refactor db boxes
- refactor navigation
- refactor `network` and `networkId` (updates api/explorer url based on ports and network suffix)
- backup sheet cleanup
- refactor settings
- support for BIP39 passphrase
- enable 12 word standard wallets
- fee non optional
- add mass calculator
- update grpc to rusty karlsen
- TKLS on testnet
- replace by fee and fee estimate rpc
- support for priority fee and rbf
- periodically update KLS price
- revert `qr_code_scanner` and `flutter_vibrate` (fix in android\build.gradle; related to the fact that now flutter checks the versions of `compileSdkVersion` and `buildToolsVersion`. Some packages either specify outdated versions or do not specify them at all)
- new white and dark theme
- bump version to `3.0.0+1`
  • Loading branch information
Leon1777 committed Nov 2, 2024
1 parent c6a727f commit 1cf4d0e
Show file tree
Hide file tree
Showing 276 changed files with 21,088 additions and 25,127 deletions.
13 changes: 13 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}

subprojects {
afterEvaluate { project ->
if (project.plugins.hasPlugin("com.android.application") ||
project.plugins.hasPlugin("com.android.library")) {
project.android {
compileSdkVersion 34
buildToolsVersion "34.0.0"
}
}
}
}

subprojects {
project.evaluationDependsOn(':app')
}
Expand Down
67 changes: 6 additions & 61 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,17 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_displaymode/flutter_displaymode.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_portal/flutter_portal.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:oktoast/oktoast.dart';

import 'app_constants.dart';
import 'app_providers.dart';
import 'app_router.dart';
import 'app_styles.dart';
import 'l10n/l10n.dart';
import 'screens/home_screen.dart';
import 'screens/intro_screen.dart';
import 'screens/lock_screen.dart';
import 'screens/logout_screen.dart';
import 'screens/password_lock_screen.dart';
import 'screens/setup_wallet_screen.dart';
import 'screens/splash_screen.dart';
import 'screens/privacy_screen.dart';
import 'themes/themes.dart';
import 'util/platform.dart';
import 'util/routes.dart';

class App extends HookConsumerWidget {
const App({Key? key}) : super(key: key);
Expand Down Expand Up @@ -51,7 +44,7 @@ class App extends HookConsumerWidget {

useEffect(() {
final appLinks = AppLinks();
final sub = appLinks.stringLinkStream.listen((appLink) {
final sub = appLinks.allStringLinkStream.listen((appLink) {
ref.read(appLinkProvider.notifier).state = appLink;
});
return sub.cancel;
Expand All @@ -66,7 +59,7 @@ class App extends HookConsumerWidget {
minHeight: 480,
maxWidth: 720,
),
child: Portal(
child: PrivacyScreen(
child: OKToast(
position: ToastPosition(align: Alignment.topCenter, offset: 40),
textStyle: styles.textStyleSnackbar,
Expand Down Expand Up @@ -104,56 +97,8 @@ class App extends HookConsumerWidget {
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
locale: language.getLocale(),
initialRoute: '/',
onGenerateRoute: (RouteSettings settings) {
switch (settings.name) {
case '/intro':
return NoTransitionRoute(
builder: (_) => const IntroScreen(),
settings: settings,
);
case '/home':
return NoTransitionRoute(
builder: (_) => const HomeScreen(),
settings: settings,
);
// case '/home_transition':
// return NoPopTransitionRoute(
// builder: (_) => const HomeScreen(),
// settings: settings,
// );
case '/lock_screen':
return NoTransitionRoute(
builder: (_) => const LockScreen(),
settings: settings,
);
case '/lock_screen_transition':
return MaterialPageRoute(
builder: (_) => const LockScreen(),
settings: settings,
);
case '/password_lock_screen':
return NoTransitionRoute(
builder: (_) => const PasswordLockScreen(),
settings: settings,
);
case '/logout':
return NoTransitionRoute(
builder: (_) => const LogoutScreen(),
settings: settings,
);
case '/wallet_setup':
return NoTransitionRoute(
builder: (_) => const SetupWalletScreen(),
settings: settings,
);
default:
return NoTransitionRoute(
builder: (_) => const SplashScreen(),
settings: settings,
);
}
},
initialRoute: appRouter.initialRoute,
onGenerateRoute: appRouter.onGenerateRoute,
),
),
),
Expand Down
1 change: 1 addition & 0 deletions lib/app_providers.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export 'coingecko/coingecko_providers.dart';
export 'contacts/contacts_providers.dart';
export 'core/core_providers.dart';
export 'node_settings/node_providers.dart';
export 'settings/settings_providers.dart';
export 'transactions/transaction_providers.dart';
export 'txnotes/txnotes_providers.dart';
Expand Down
121 changes: 121 additions & 0 deletions lib/app_router.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import 'package:flutter/material.dart';

import 'screens/screens.dart';
import 'util/routes.dart';

final appRouter = AppRouter();

class _AppScreens {
static const splash = '/';
static const intro = '/intro';
static const wallet = '/wallet';
static const locked = '/locked';
static const lockedWithTransition = '/locked_with_transition';
static const passwordLocked = '/password_locked';
static const logout = '/logout';
static const setupWallet = '/setup_wallet';
}

class AppRouter {
void reload(BuildContext context) =>
_replaceWith(_AppScreens.splash, context);

void startIntro(BuildContext context) =>
_replaceWith(_AppScreens.intro, context);

void setupWallet(BuildContext context) =>
_replaceWith(_AppScreens.setupWallet, context);

void requireUnlock(BuildContext context) =>
_replaceWith(_AppScreens.locked, context);

void lockoutkWithTransition(BuildContext context) =>
_replaceWith(_AppScreens.lockedWithTransition, context);

void requirePassword(BuildContext context) =>
_replaceWith(_AppScreens.passwordLocked, context);

void openWallet(BuildContext context) =>
_replaceWith(_AppScreens.wallet, context);

void logout(BuildContext context) =>
_replaceWith(_AppScreens.logout, context);

bool isTopRoute<T>(BuildContext context) {
bool isTopRoute = false;
Navigator.of(context).popUntil((route) {
isTopRoute = route is T;
return true;
});
return isTopRoute;
}

Future<T?> _replaceWith<T>(String screenName, BuildContext context) {
return Navigator.of(context).pushNamedAndRemoveUntil(
screenName,
(_) => false,
);
}

Future<T?> push<T>(BuildContext context, Route<T> route) {
return Navigator.of(context).push(route);
}

void pop<T>(BuildContext context, {T? withResult = null}) {
Navigator.of(context).pop(withResult);
}

Future<T?> pushAndRemoveUntilHome<T>(BuildContext context, Route<T> route) {
return Navigator.of(context).pushAndRemoveUntil(
route,
RouteUtils.withNameLike(_AppScreens.wallet),
);
}

String initialRoute = _AppScreens.splash;

RouteFactory onGenerateRoute = (RouteSettings settings) {
switch (settings.name) {
case _AppScreens.intro:
return NoTransitionRoute(
builder: (_) => const IntroScreen(),
settings: settings,
);
case _AppScreens.wallet:
return NoTransitionRoute(
builder: (_) => const HomeScreen(),
settings: settings,
);
case _AppScreens.locked:
return BarrierRoute(
builder: (_) => const LockScreen(),
settings: settings,
);
case _AppScreens.lockedWithTransition:
return BarrierRoute(
builder: (_) => const LockScreen(),
settings: settings,
);
case _AppScreens.passwordLocked:
return NoTransitionRoute(
builder: (_) => const PasswordLockScreen(),
settings: settings,
);
case _AppScreens.logout:
return NoTransitionRoute(
builder: (_) => const LogoutScreen(),
settings: settings,
);
case _AppScreens.setupWallet:
return NoTransitionRoute(
builder: (_) => const SetupWalletScreen(),
settings: settings,
);
default:
return NoTransitionRoute(
builder: (_) => const SplashScreen(),
settings: settings,
);
}
};
}
9 changes: 0 additions & 9 deletions lib/app_styles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1136,15 +1136,6 @@ class AppStyles {
if (states.contains(WidgetState.pressed)) return theme.success30;
return null;
}),
// side: MaterialStateProperty.resolveWith<BorderSide?>(
// (Set<MaterialState> states) {
// if (states.contains(MaterialState.pressed))
// return BorderSide(
// color: theme.primary,
// width: 2,
// );
// return null;
// }),
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/chain_state/chain_state.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '../settings/settings_providers.dart';
import '../settings/settings_repository.dart';
import 'chain_state_types.dart';

export 'chain_state_types.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/coingecko/coingecko_price_notifier.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../app_providers.dart';
import '../settings/settings_repository.dart';
import 'coingecko_types.dart';

const _kCoinGeckoPriceKey = '_coingeckoPriceKey';
Expand Down
12 changes: 7 additions & 5 deletions lib/coingecko/coingecko_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ final _karlsenPriceCacheProvider =
return CoinGeckoPriceNotifier(repository);
});

final _karlsenPriceRemoteProvider = FutureProvider<CoinGeckoPrice>((ref) async {
final _karlsenPriceRemoteProvider =
FutureProvider.autoDispose<CoinGeckoPrice>((ref) async {
ref.watch(remoteRefreshProvider);
ref.watch(timeProvider);

final currency = ref.watch(currencyProvider);
final fiat = currency.name.toLowerCase();
Expand All @@ -24,9 +26,9 @@ final _karlsenPriceRemoteProvider = FutureProvider<CoinGeckoPrice>((ref) async {

// 60 seconds
final maxCacheAge = 60 * 1000;
final nowTimestamp = DateTime.now().millisecondsSinceEpoch;
final timestamp = DateTime.now().millisecondsSinceEpoch;
if (cached.currency == currency.currency &&
nowTimestamp - cached.timestamp < maxCacheAge) {
timestamp - cached.timestamp < maxCacheAge) {
log.d('Using cached CoinGecko exchange rates');
return cached;
}
Expand All @@ -40,7 +42,7 @@ final _karlsenPriceRemoteProvider = FutureProvider<CoinGeckoPrice>((ref) async {
return CoinGeckoPrice(
currency: currency.currency,
price: Decimal.parse(price.toString()),
timestamp: nowTimestamp,
timestamp: timestamp,
);
} catch (e, st) {
log.e('Failed to fetch KLS exchange rate', error: e, stackTrace: st);
Expand All @@ -50,7 +52,7 @@ final _karlsenPriceRemoteProvider = FutureProvider<CoinGeckoPrice>((ref) async {
return CoinGeckoPrice(
currency: currency.currency,
price: Decimal.zero,
timestamp: nowTimestamp,
timestamp: timestamp,
);
}
});
Expand Down
Loading

0 comments on commit 1cf4d0e

Please sign in to comment.