Merge pull request #1034 from cypherstack/paynym-changes

Various changes
This commit is contained in:
Diego Salazar 2024-11-22 15:51:23 -07:00 committed by GitHub
commit f38efd35e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 241 additions and 217 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

View file

@ -10,7 +10,6 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
@ -131,11 +130,6 @@ class _AddWalletViewState extends ConsumerState<AddWalletView> {
void initState() {
_searchFieldController = TextEditingController();
_searchFocusNode = FocusNode();
// _coinsTestnet.remove(Coin.firoTestNet);
if (Util.isDesktop && !kDebugMode) {
_coins.removeWhere((e) => e is BitcoinFrost);
}
coinEntities.addAll(_coins.map((e) => CoinEntity(e)));

View file

@ -13,6 +13,7 @@ import '../../widgets/churning/churn_progress_item.dart';
import '../../widgets/custom_buttons/app_bar_icon_button.dart';
import '../../widgets/desktop/primary_button.dart';
import '../../widgets/desktop/secondary_button.dart';
import '../../widgets/monero_chan_dance.dart';
import '../../widgets/rounded_container.dart';
import '../../widgets/stack_dialog.dart';
import 'churn_error_dialog.dart';
@ -185,6 +186,10 @@ class _ChurningProgressViewState extends ConsumerState<ChurningProgressView> {
const SizedBox(
height: 20,
),
const MoneroChanDance(),
const SizedBox(
height: 20,
),
ProgressItem(
iconAsset: Assets.svg.alertCircle,
label: "Waiting for balance to unlock ${ref.watch(

View file

@ -382,13 +382,15 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
),
child: Row(
children: [
Expanded(
child: PaynymFollowToggleButton(
walletId: widget.walletId,
paymentCodeStringToFollow: widget.accountLite.code,
style: PaynymFollowToggleButtonStyle.detailsPopup,
),
),
kDisableFollowing
? const Spacer()
: Expanded(
child: PaynymFollowToggleButton(
walletId: widget.walletId,
paymentCodeStringToFollow: widget.accountLite.code,
style: PaynymFollowToggleButtonStyle.detailsPopup,
),
),
const SizedBox(
width: 12,
),

View file

@ -14,7 +14,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';
import '../../models/paynym/paynym_account.dart';
import '../../providers/global/paynym_api_provider.dart';
import '../../providers/global/wallets_provider.dart';
import '../../providers/wallet/my_paynym_account_state_provider.dart';
@ -47,25 +46,25 @@ class PaynymClaimView extends ConsumerStatefulWidget {
}
class _PaynymClaimViewState extends ConsumerState<PaynymClaimView> {
Future<bool> _addSegwitCode(PaynymAccount myAccount) async {
final wallet =
ref.read(pWallets).getWallet(widget.walletId) as PaynymInterface;
final token = await ref
.read(paynymAPIProvider)
.token(myAccount.nonSegwitPaymentCode.code);
final signature = await wallet.signStringWithNotificationKey(token.value!);
final pCodeSegwit = await wallet.getPaymentCode(isSegwit: true);
final addResult = await ref.read(paynymAPIProvider).add(
token.value!,
signature,
myAccount.nymID,
pCodeSegwit.toString(),
);
return addResult.value ?? false;
}
// Future<bool> _addSegwitCode(PaynymAccount myAccount) async {
// final wallet =
// ref.read(pWallets).getWallet(widget.walletId) as PaynymInterface;
//
// final token = await ref
// .read(paynymAPIProvider)
// .token(myAccount.nonSegwitPaymentCode.code);
// final signature = await wallet.signStringWithNotificationKey(token.value!);
//
// final pCodeSegwit = await wallet.getPaymentCode(isSegwit: true);
// final addResult = await ref.read(paynymAPIProvider).add(
// token.value!,
// signature,
// myAccount.nymID,
// pCodeSegwit.toString(),
// );
//
// return addResult.value ?? false;
// }
@override
Widget build(BuildContext context) {
@ -210,16 +209,16 @@ class _PaynymClaimViewState extends ConsumerState<PaynymClaimView> {
// payment code already claimed
debugPrint("pcode already claimed!!");
final account =
await ref.read(paynymAPIProvider).nym(pCode.toString());
if (!account.value!.segwit) {
for (int i = 0; i < 100; i++) {
final result = await _addSegwitCode(account.value!);
if (result == true) {
break;
}
}
}
// final account =
// await ref.read(paynymAPIProvider).nym(pCode.toString());
// if (!account.value!.segwit) {
// for (int i = 0; i < 100; i++) {
// final result = await _addSegwitCode(account.value!);
// if (result == true) {
// break;
// }
// }
// }
if (mounted) {
if (isDesktop) {
@ -259,14 +258,14 @@ class _PaynymClaimViewState extends ConsumerState<PaynymClaimView> {
if (claim.value?.claimed == pCode.toString()) {
final account =
await ref.read(paynymAPIProvider).nym(pCode.toString());
if (!account.value!.segwit) {
for (int i = 0; i < 100; i++) {
final result = await _addSegwitCode(account.value!);
if (result == true) {
break;
}
}
}
// if (!account.value!.segwit) {
// for (int i = 0; i < 100; i++) {
// final result = await _addSegwitCode(account.value!);
// if (result == true) {
// break;
// }
// }
// }
ref.read(myPaynymAccountStateProvider.state).state =
account.value!;

View file

@ -27,6 +27,7 @@ import '../../utilities/text_styles.dart';
import '../../utilities/util.dart';
import '../../widgets/conditional_parent.dart';
import '../../widgets/custom_buttons/app_bar_icon_button.dart';
import '../../widgets/custom_buttons/paynym_follow_toggle_button.dart';
import '../../widgets/desktop/desktop_app_bar.dart';
import '../../widgets/desktop/desktop_scaffold.dart';
import '../../widgets/desktop/secondary_button.dart';
@ -121,72 +122,75 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
),
],
),
trailing: Padding(
padding: const EdgeInsets.only(right: 12),
child: SizedBox(
height: 56,
child: MouseRegion(
cursor: SystemMouseCursors.click,
onEnter: (_) => setState(() {
_followButtonHoverState = true;
}),
onExit: (_) => setState(() {
_followButtonHoverState = false;
}),
child: GestureDetector(
onTap: () {
showDialog<void>(
context: context,
builder: (context) => AddNewPaynymFollowView(
walletId: widget.walletId,
),
);
},
child: RoundedContainer(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
color: _followButtonHoverState
? Theme.of(context)
.extension<StackColors>()!
.highlight
: Colors.transparent,
radiusMultiplier: 100,
child: Row(
children: [
SvgPicture.asset(
Assets.svg.plus,
width: 16,
height: 16,
color: Theme.of(context)
.extension<StackColors>()!
.textDark,
),
const SizedBox(
width: 8,
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Follow",
style:
STextStyles.desktopButtonSecondaryEnabled(
context,
).copyWith(
fontSize: 16,
trailing: kDisableFollowing
? null
: Padding(
padding: const EdgeInsets.only(right: 12),
child: SizedBox(
height: 56,
child: MouseRegion(
cursor: SystemMouseCursors.click,
onEnter: (_) => setState(() {
_followButtonHoverState = true;
}),
onExit: (_) => setState(() {
_followButtonHoverState = false;
}),
child: GestureDetector(
onTap: () {
showDialog<void>(
context: context,
builder: (context) => AddNewPaynymFollowView(
walletId: widget.walletId,
),
);
},
child: RoundedContainer(
padding:
const EdgeInsets.symmetric(horizontal: 24.0),
color: _followButtonHoverState
? Theme.of(context)
.extension<StackColors>()!
.highlight
: Colors.transparent,
radiusMultiplier: 100,
child: Row(
children: [
SvgPicture.asset(
Assets.svg.plus,
width: 16,
height: 16,
color: Theme.of(context)
.extension<StackColors>()!
.textDark,
),
),
const SizedBox(
height: 2,
),
],
const SizedBox(
width: 8,
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Follow",
style: STextStyles
.desktopButtonSecondaryEnabled(
context,
).copyWith(
fontSize: 16,
),
),
const SizedBox(
height: 2,
),
],
),
],
),
),
],
),
),
),
),
),
),
),
)
: AppBar(
leading: AppBarBackButton(
@ -201,28 +205,29 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
overflow: TextOverflow.ellipsis,
),
actions: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
child: AspectRatio(
aspectRatio: 1,
child: AppBarIconButton(
icon: SvgPicture.asset(
Assets.svg.circlePlusFilled,
width: 20,
height: 20,
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
if (!kDisableFollowing)
Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
child: AspectRatio(
aspectRatio: 1,
child: AppBarIconButton(
icon: SvgPicture.asset(
Assets.svg.circlePlusFilled,
width: 20,
height: 20,
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
onPressed: () {
Navigator.of(context).pushNamed(
AddNewPaynymFollowView.routeName,
arguments: widget.walletId,
);
},
),
onPressed: () {
Navigator.of(context).pushNamed(
AddNewPaynymFollowView.routeName,
arguments: widget.walletId,
);
},
),
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
child: AspectRatio(

View file

@ -284,13 +284,17 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
const SizedBox(
width: 20,
),
Expanded(
child: PaynymFollowToggleButton(
walletId: widget.walletId,
paymentCodeStringToFollow: widget.accountLite.code,
style: PaynymFollowToggleButtonStyle.detailsDesktop,
),
),
kDisableFollowing
? const Spacer()
: Expanded(
child: PaynymFollowToggleButton(
walletId: widget.walletId,
paymentCodeStringToFollow:
widget.accountLite.code,
style:
PaynymFollowToggleButtonStyle.detailsDesktop,
),
),
],
),
if (_showInsufficientFundsInfo)

View file

@ -9,12 +9,13 @@
*/
import 'package:flutter/material.dart';
import 'paynym_bot.dart';
import '../../../themes/stack_colors.dart';
import '../../../utilities/format.dart';
import '../../../utilities/text_styles.dart';
import '../../../utilities/util.dart';
import '../../../widgets/custom_buttons/paynym_follow_toggle_button.dart';
import 'paynym_bot.dart';
class PaynymCard extends StatefulWidget {
const PaynymCard({
@ -84,10 +85,11 @@ class _PaynymCardState extends State<PaynymCard> {
],
),
),
PaynymFollowToggleButton(
walletId: widget.walletId,
paymentCodeStringToFollow: widget.paymentCodeString,
),
if (!kDisableFollowing)
PaynymFollowToggleButton(
walletId: widget.walletId,
paymentCodeStringToFollow: widget.paymentCodeString,
),
],
),
);

View file

@ -48,6 +48,7 @@ import '../../../../widgets/background.dart';
import '../../../../widgets/conditional_parent.dart';
import '../../../../widgets/custom_buttons/app_bar_icon_button.dart';
import '../../../../widgets/custom_buttons/blue_text_button.dart';
import '../../../../widgets/custom_buttons/simple_copy_button.dart';
import '../../../../widgets/desktop/desktop_dialog.dart';
import '../../../../widgets/desktop/desktop_dialog_close_button.dart';
import '../../../../widgets/desktop/primary_button.dart';
@ -1722,16 +1723,27 @@ class _TransactionV2DetailsViewState
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
"Transaction ID",
style: isDesktop
? STextStyles
.desktopTextExtraExtraSmall(
context,
)
: STextStyles.itemSubtitle(
context,
),
ConditionalParent(
condition: !isDesktop,
builder: (child) => Row(
children: [
Expanded(child: child),
SimpleCopyButton(
data: _transaction.txid,
),
],
),
child: Text(
"Transaction ID",
style: isDesktop
? STextStyles
.desktopTextExtraExtraSmall(
context,
)
: STextStyles.itemSubtitle(
context,
),
),
),
const SizedBox(
height: 8,

View file

@ -1175,8 +1175,10 @@ class _WalletViewState extends ConsumerState<WalletView> {
// check if account exists and for matching code to see if claimed
if (account.value != null &&
account.value!.nonSegwitPaymentCode.claimed &&
account.value!.segwit) {
account.value!.nonSegwitPaymentCode.claimed
// &&
// account.value!.segwit
) {
ref.read(myPaynymAccountStateProvider.state).state =
account.value!;

View file

@ -15,6 +15,7 @@ import '../../../widgets/desktop/desktop_dialog.dart';
import '../../../widgets/desktop/desktop_dialog_close_button.dart';
import '../../../widgets/desktop/primary_button.dart';
import '../../../widgets/desktop/secondary_button.dart';
import '../../../widgets/monero_chan_dance.dart';
import '../../../widgets/rounded_container.dart';
import '../../../widgets/rounded_white_container.dart';
@ -235,6 +236,10 @@ class _ChurnDialogViewState extends ConsumerState<ChurnDialogView> {
const SizedBox(
height: 20,
),
const MoneroChanDance(),
const SizedBox(
height: 20,
),
ProgressItem(
iconAsset: Assets.svg.alertCircle,
label: "Waiting for balance to unlock ${ref.watch(

View file

@ -302,13 +302,14 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {
level: LogLevel.Info,
);
if (context.mounted) {
if (mounted) {
Navigator.of(context, rootNavigator: true).pop();
// check if account exists and for matching code to see if claimed
if (account.value != null &&
account.value!.nonSegwitPaymentCode.claimed &&
account.value!.segwit) {
if (account.value != null && account.value!.nonSegwitPaymentCode.claimed
// &&
// account.value!.segwit
) {
ref.read(myPaynymAccountStateProvider.state).state = account.value!;
await Navigator.of(context).pushNamed(

View file

@ -33,7 +33,7 @@ final pThemeService = Provider<ThemeService>((ref) {
class ThemeService {
// dumb quick conditional based on name. Should really be done better
static const _currentDefaultThemeVersion =
AppConfig.appName == "Campfire" ? 17 : 15;
AppConfig.appName == "Campfire" ? 17 : 16;
ThemeService._();
static ThemeService? _instance;
static ThemeService get instance => _instance ??= ThemeService._();
@ -120,70 +120,42 @@ class ThemeService {
Future<void> checkDefaultThemesOnStartup() async {
// install default themes
if (!(await ThemeService.instance.verifyInstalled(themeId: "light"))) {
Logging.instance.log(
"Installing default light theme...",
level: LogLevel.Info,
);
final lightZip = await rootBundle.load("assets/default_themes/light.zip");
await ThemeService.instance
.install(themeArchiveData: lightZip.buffer.asUint8List());
Logging.instance.log(
"Installing default light theme... finished",
level: LogLevel.Info,
);
await _updateDefaultTheme("light");
} else {
// check installed version
final theme = ThemeService.instance.getTheme(themeId: "light");
if ((theme?.version ?? 1) < _currentDefaultThemeVersion) {
Logging.instance.log(
"Updating default light theme...",
level: LogLevel.Info,
);
final lightZip =
await rootBundle.load("assets/default_themes/light.zip");
await ThemeService.instance
.install(themeArchiveData: lightZip.buffer.asUint8List());
Logging.instance.log(
"Updating default light theme... finished",
level: LogLevel.Info,
);
await _updateDefaultTheme("light");
}
}
if (AppConfig.hasFeature(AppFeature.themeSelection)) {
if (!(await ThemeService.instance.verifyInstalled(themeId: "dark"))) {
Logging.instance.log(
"Installing default dark theme... ",
level: LogLevel.Info,
);
final darkZip = await rootBundle.load("assets/default_themes/dark.zip");
await ThemeService.instance
.install(themeArchiveData: darkZip.buffer.asUint8List());
Logging.instance.log(
"Installing default dark theme... finished",
level: LogLevel.Info,
);
await _updateDefaultTheme("dark");
} else {
// check installed version
// final theme = ThemeService.instance.getTheme(themeId: "dark");
// Force update theme to add missing icons for now
// TODO: uncomment if statement in future when themes are version 4 or above
// if ((theme?.version ?? 1) < _currentDefaultThemeVersion) {
Logging.instance.log(
"Updating default dark theme...",
level: LogLevel.Info,
);
final darkZip = await rootBundle.load("assets/default_themes/dark.zip");
await ThemeService.instance
.install(themeArchiveData: darkZip.buffer.asUint8List());
Logging.instance.log(
"Updating default dark theme... finished",
level: LogLevel.Info,
);
// }
final theme = ThemeService.instance.getTheme(themeId: "dark");
if ((theme?.version ?? 1) < _currentDefaultThemeVersion) {
await _updateDefaultTheme("dark");
}
}
}
}
Future<void> _updateDefaultTheme(String name) async {
Logging.instance.log(
"Updating default $name theme...",
level: LogLevel.Info,
);
final zip = await rootBundle.load("assets/default_themes/$name.zip");
await ThemeService.instance.install(
themeArchiveData: zip.buffer.asUint8List(),
);
Logging.instance.log(
"Updating default $name theme... finished",
level: LogLevel.Info,
);
}
// TODO more thorough check/verification of theme
Future<bool> verifyInstalled({required String themeId}) async {
final theme =

View file

@ -279,4 +279,5 @@ class _GIF {
const _GIF();
String get stacyOnion => "assets/gif/stacy_onion.gif";
String get moneroChanDance => "assets/gif/monero-chan-dance.gif";
}

View file

@ -34,6 +34,8 @@ enum PaynymFollowToggleButtonStyle {
detailsDesktop,
}
const kDisableFollowing = true;
class PaynymFollowToggleButton extends ConsumerStatefulWidget {
const PaynymFollowToggleButton({
super.key,
@ -55,7 +57,7 @@ class _PaynymFollowToggleButtonState
extends ConsumerState<PaynymFollowToggleButton> {
final isDesktop = Util.isDesktop;
Future<bool> follow() async {
Future<bool> _follow() async {
bool loadingPopped = false;
unawaited(
showDialog<void>(
@ -160,7 +162,7 @@ class _PaynymFollowToggleButtonState
}
}
Future<bool> unfollow() async {
Future<bool> _unfollow() async {
bool loadingPopped = false;
unawaited(
showDialog<void>(
@ -264,9 +266,9 @@ class _PaynymFollowToggleButtonState
if (!_lock) {
_lock = true;
if (isFollowing) {
await unfollow();
await _unfollow();
} else {
await follow();
await _follow();
}
_lock = false;
}
@ -291,7 +293,7 @@ class _PaynymFollowToggleButtonState
width: isDesktop ? 120 : 100,
buttonHeight: isDesktop ? ButtonHeight.s : ButtonHeight.xl,
label: isFollowing ? "Unfollow" : "Follow",
onPressed: _onPressed,
onPressed: kDisableFollowing ? null : _onPressed,
);
case PaynymFollowToggleButtonStyle.detailsPopup:
@ -306,7 +308,7 @@ class _PaynymFollowToggleButtonState
color:
Theme.of(context).extension<StackColors>()!.buttonTextSecondary,
),
onPressed: _onPressed,
onPressed: kDisableFollowing ? null : _onPressed,
);
case PaynymFollowToggleButtonStyle.detailsDesktop:
@ -321,7 +323,7 @@ class _PaynymFollowToggleButtonState
Theme.of(context).extension<StackColors>()!.buttonTextSecondary,
),
iconSpacing: 6,
onPressed: _onPressed,
onPressed: kDisableFollowing ? null : _onPressed,
);
}
}

View file

@ -0,0 +1,18 @@
import 'package:flutter/material.dart';
import '../utilities/assets.dart';
class MoneroChanDance extends StatelessWidget {
const MoneroChanDance({super.key, this.height = 200});
final double height;
@override
Widget build(BuildContext context) {
return Image(
height: height,
image: AssetImage(
Assets.gif.moneroChanDance,
),
);
}
}