Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions assets/config/v5/communities.json
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,14 @@
"desc": "SFLUV has migrated from Polygon to BeraChain, so this community (SFLUV Polygon) has been closed. Click the link below to create an account in the new SFLUV community. Your SFLUV Polygon balance will be transferred over once you have a new account.",
"button": "Migrate"
}
},
{
"url": "https://app.sfluv.org/map",
"icon": "https://assets.citizenwallet.xyz/wallet-config/_images/sfluv.svg",
"name": "Map",
"featured": true,
"signature": true,
"launch_mode": "webview"
}
],
"version": 5,
Expand All @@ -483,6 +491,8 @@
"logo": "https://assets.citizenwallet.xyz/wallet-config/_images/sfluv.svg",
"name": "SFLUV Community (Polygon)",
"alias": "wallet.sfluv.org",
"hidden": true,
"closed": true,
"theme": {
"primary": "#eb6c6c"
},
Expand Down
10 changes: 10 additions & 0 deletions assets/config/v5/communities.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,14 @@
"desc": "SFLUV has migrated from Polygon to BeraChain, so this community (SFLUV Polygon) has been closed. Click the link below to create an account in the new SFLUV community. Your SFLUV Polygon balance will be transferred over once you have a new account.",
"button": "Migrate"
}
},
{
"url": "https://app.sfluv.org/map",
"icon": "https://assets.citizenwallet.xyz/wallet-config/_images/sfluv.svg",
"name": "Map",
"featured": true,
"signature": true,
"launch_mode": "webview"
}
],
"version": 5,
Expand All @@ -483,6 +491,8 @@
"logo": "https://assets.citizenwallet.xyz/wallet-config/_images/sfluv.svg",
"name": "SFLUV Community (Polygon)",
"alias": "wallet.sfluv.org",
"hidden": true,
"closed": true,
"theme": {
"primary": "#eb6c6c"
},
Expand Down
94 changes: 78 additions & 16 deletions lib/screens/wallet/screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class WalletScreenState extends State<WalletScreen>
String? _sendToURL;
Config? _config;
bool _isClosedBannerDismissed = false;
int _bannerResetKey = 0;

@override
void initState() {
Expand Down Expand Up @@ -152,6 +153,20 @@ class WalletScreenState extends State<WalletScreen>
}
}

@override
Future<void> didChangeAppLifecycleState(AppLifecycleState state) async {
switch (state) {
case AppLifecycleState.resumed:
_logic.updateWalletConfigFromRemote();
setState(() {
_isClosedBannerDismissed = false;
_bannerResetKey++;
});
break;
default:
}
}

void onScrollUpdate() {
if (_scrollController.position.pixels >=
_scrollController.position.maxScrollExtent - 300) {
Expand Down Expand Up @@ -374,6 +389,11 @@ class WalletScreenState extends State<WalletScreen>
_profileLogic.resume();
_profilesLogic.resume();
_voucherLogic.resume();
_logic.updateWalletConfigFromRemote();
setState(() {
_isClosedBannerDismissed = false;
_bannerResetKey++;
});

navigator.go('/wallet/$_address');
}
Expand Down Expand Up @@ -595,17 +615,28 @@ class WalletScreenState extends State<WalletScreen>
_profileLogic.resume();
_profilesLogic.resume();
_voucherLogic.resume();
_logic.updateWalletConfigFromRemote();
setState(() {
_isClosedBannerDismissed = false;
_bannerResetKey++;
});
}

void handleReceive() async {
HapticFeedback.heavyImpact();

final navigator = GoRouter.of(context);

navigator.push('/wallet/$_address/receive', extra: {
await navigator.push('/wallet/$_address/receive', extra: {
'logic': _logic,
'profilesLogic': _profilesLogic,
});

_logic.updateWalletConfigFromRemote();
setState(() {
_isClosedBannerDismissed = false;
_bannerResetKey++;
});
}

Future<void> handlePlugin(PluginConfig pluginConfig) async {
Expand Down Expand Up @@ -700,6 +731,11 @@ class WalletScreenState extends State<WalletScreen>
_profileLogic.resume();
_profilesLogic.resume();
_voucherLogic.resume();
_logic.updateWalletConfigFromRemote();
setState(() {
_isClosedBannerDismissed = false;
_bannerResetKey++;
});
}

Future<void> handleMint({String? receiveParams}) async {
Expand All @@ -721,6 +757,11 @@ class WalletScreenState extends State<WalletScreen>
_profileLogic.resume();
_profilesLogic.resume();
_voucherLogic.resume();
_logic.updateWalletConfigFromRemote();
setState(() {
_isClosedBannerDismissed = false;
_bannerResetKey++;
});
}

void handleVouchers() async {
Expand All @@ -742,6 +783,11 @@ class WalletScreenState extends State<WalletScreen>
_profileLogic.resume();
_profilesLogic.resume();
_voucherLogic.resume();
_logic.updateWalletConfigFromRemote();
setState(() {
_isClosedBannerDismissed = false;
_bannerResetKey++;
});
}

void handleCopy(String value) {
Expand All @@ -768,6 +814,11 @@ class WalletScreenState extends State<WalletScreen>
_profileLogic.resume();
_profilesLogic.resume();
_voucherLogic.resume();
_logic.updateWalletConfigFromRemote();
setState(() {
_isClosedBannerDismissed = false;
_bannerResetKey++;
});
}

void handleLoad(String address) async {
Expand All @@ -785,13 +836,23 @@ class WalletScreenState extends State<WalletScreen>

if (args == null) {
_logic.resumeFetching();
_logic.updateWalletConfigFromRemote();
setState(() {
_isClosedBannerDismissed = false;
_bannerResetKey++;
});
return;
}

final (address, alias) = args;

if (address == _address && alias == _alias) {
_logic.resumeFetching();
_logic.updateWalletConfigFromRemote();
setState(() {
_isClosedBannerDismissed = false;
_bannerResetKey++;
});
return;
}

Expand Down Expand Up @@ -1201,13 +1262,14 @@ class WalletScreenState extends State<WalletScreen>
final isOffline = eventServiceState == EventServiceState.error ||
eventServiceState == EventServiceState.connecting;

final isCommunityClosed = eventServiceState == EventServiceState.closed;
final config = context.select((WalletState state) => state.config);
final isCommunityClosed = eventServiceState == EventServiceState.closed ||
(config?.community.closed ?? false);
final offboardPlugin = context.select(
(WalletState state) => state.config!.getOffboardPlugin(),
);

final cleaningUp = context.select((WalletState state) => state.cleaningUp);
final config = context.select((WalletState state) => state.config);
final hasActiveSessions =
context.select((WalletConnectState state) => state.hasActiveSessions);

Expand Down Expand Up @@ -1401,19 +1463,19 @@ class WalletScreenState extends State<WalletScreen>
),
),
),
if (isCommunityClosed)
CommunityClosedBanner(
handleOffboardPlugin: offboardPlugin != null
? () => handlePlugin(offboardPlugin)
: null,
onDismiss: () {
setState(() {
_isClosedBannerDismissed = true;
});
},
display: isCommunityClosed,
offboardPlugin: offboardPlugin,
),
CommunityClosedBanner(
key: ValueKey('community_closed_banner_$_bannerResetKey'),
handleOffboardPlugin: offboardPlugin != null
? () => handlePlugin(offboardPlugin)
: null,
onDismiss: () {
setState(() {
_isClosedBannerDismissed = true;
});
},
display: isCommunityClosed && !_isClosedBannerDismissed,
offboardPlugin: offboardPlugin,
),
OfflineBanner(
communityUrl: config?.community.url ?? '',
display: isOffline,
Expand Down
4 changes: 4 additions & 0 deletions lib/services/config/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class CommunityConfig {
final String logo;
final String? customDomain;
final bool hidden;
final bool closed;
final ColorTheme theme;
final ContractLocation profile;
final ContractLocation primaryToken;
Expand All @@ -76,6 +77,7 @@ class CommunityConfig {
required this.logo,
this.customDomain,
this.hidden = false,
this.closed = false,
required this.theme,
required this.profile,
required this.primaryToken,
Expand All @@ -96,6 +98,7 @@ class CommunityConfig {
logo: json['logo'] ?? '',
customDomain: json['custom_domain'],
hidden: json['hidden'] ?? false,
closed: json['closed'] ?? false,
theme: theme,
profile: ContractLocation.fromJson(json['profile']),
primaryToken: ContractLocation.fromJson(json['primary_token']),
Expand All @@ -117,6 +120,7 @@ class CommunityConfig {
'logo': logo,
'custom_domain': customDomain,
'hidden': hidden,
'closed': closed,
'theme': theme,
'profile': profile.toJson(),
'primary_token': primaryToken.toJson(),
Expand Down