Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
quetool committed Jan 9, 2024
1 parent 74c9573 commit 4e0243e
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 22 deletions.
17 changes: 14 additions & 3 deletions example/dapp/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ class _MyHomePageState extends State<MyHomePage> {
projectId: DartDefines.projectId,
logLevel: LogLevel.info,
metadata: const PairingMetadata(
name: 'Flutter WalletConnect',
description: 'Flutter WalletConnect Dapp Example',
name: 'Example dApp',
description: 'Example dApp',
url: 'https://walletconnect.com/',
icons: ['https://walletconnect.com/walletconnect-logo.png'],
icons: [
'https://images.prismic.io/wallet-connect/65785a56531ac2845a260732_WalletConnect-App-Logo-1024X1024.png'
],
redirect: Redirect(
native: 'myflutterdapp://',
universal: 'https://walletconnect.com',
Expand All @@ -82,13 +84,15 @@ class _MyHomePageState extends State<MyHomePage> {
for (final ChainMetadata chain in ChainData.allChains) {
// Loop through the events for that chain
for (final event in getChainEvents(chain.type)) {
debugPrint('registerEventHandler $event for chain ${chain.chainId}');
_web3App!.registerEventHandler(chainId: chain.chainId, event: event);
}
}

// Register event handlers
_web3App!.onSessionPing.subscribe(_onSessionPing);
_web3App!.onSessionEvent.subscribe(_onSessionEvent);
_web3App!.onSessionUpdate.subscribe(_onSessionUpdate);
_web3App!.core.relayClient.onRelayClientConnect.subscribe(_setState);
_web3App!.core.relayClient.onRelayClientDisconnect.subscribe(_setState);
_web3App!.onSessionConnect.subscribe(_onSessionConnect);
Expand Down Expand Up @@ -133,6 +137,7 @@ class _MyHomePageState extends State<MyHomePage> {
_web3App!.core.relayClient.onRelayClientDisconnect.unsubscribe(_setState);
_web3App!.onSessionPing.unsubscribe(_onSessionPing);
_web3App!.onSessionEvent.unsubscribe(_onSessionEvent);
_web3App!.onSessionUpdate.unsubscribe(_onSessionUpdate);
super.dispose();
}

Expand Down Expand Up @@ -241,6 +246,7 @@ class _MyHomePageState extends State<MyHomePage> {
}

void _onSessionPing(SessionPing? args) {
debugPrint('[$runtimeType] _onSessionPing $args');
showDialog(
context: context,
builder: (BuildContext context) {
Expand All @@ -253,6 +259,7 @@ class _MyHomePageState extends State<MyHomePage> {
}

void _onSessionEvent(SessionEvent? args) {
debugPrint('[$runtimeType] _onSessionEvent $args');
showDialog(
context: context,
builder: (BuildContext context) {
Expand All @@ -268,4 +275,8 @@ class _MyHomePageState extends State<MyHomePage> {
void _onSessionConnect(SessionConnect? event) {
debugPrint(jsonEncode(event?.session.toJson()));
}

void _onSessionUpdate(SessionUpdate? args) {
debugPrint('[$runtimeType] _onSessionUpdate $args');
}
}
11 changes: 6 additions & 5 deletions example/dapp/lib/pages/sessions_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ class SessionsPageState extends State<SessionsPage> {
children: [
Container(
constraints: const BoxConstraints(
maxWidth: 200,
minWidth: 150,
maxWidth: 150,
),
decoration: const BoxDecoration(
border: Border(
Expand Down Expand Up @@ -79,9 +78,11 @@ class SessionsPageState extends State<SessionsPage> {
),
Expanded(
child: Container(
// color: StyleConstants.primaryColor,
padding: const EdgeInsets.all(
StyleConstants.linear8,
padding: const EdgeInsets.only(
left: StyleConstants.linear8,
top: StyleConstants.linear8,
right: StyleConstants.linear8,
bottom: StyleConstants.linear72,
),
child: _buildSessionView(),
),
Expand Down
2 changes: 1 addition & 1 deletion example/wallet/lib/dependencies/web3wallet_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Web3WalletService extends IWeb3WalletService {
description: 'Example Wallet',
url: 'https://walletconnect.com/',
icons: [
'https://github.com/WalletConnect/Web3ModalFlutter/blob/master/assets/png/logo_wc.png'
'https://images.prismic.io/wallet-connect/65785a56531ac2845a260732_WalletConnect-App-Logo-1024X1024.png'
],
redirect: Redirect(
native: 'myflutterwallet://',
Expand Down
5 changes: 4 additions & 1 deletion example/wallet/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ class _MyHomePageState extends State<MyHomePage> with GetItStateMixin {

return Scaffold(
appBar: AppBar(
title: Text(_pageDatas[_selectedIndex].title),
title: Text(
_pageDatas[_selectedIndex].title,
style: const TextStyle(color: Colors.white),
),
),
bottomNavigationBar:
MediaQuery.of(context).size.width < Constants.smallScreen
Expand Down
17 changes: 9 additions & 8 deletions example/wallet/lib/pages/app_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,18 @@ class AppDetailPageState extends State<AppDetailPage> {

return Scaffold(
appBar: AppBar(
title: Text(widget.pairing.peerMetadata?.name ?? 'Unknown'),
title: Text(
widget.pairing.peerMetadata?.name ?? 'Unknown',
style: const TextStyle(color: Colors.white),
),
),
body: SingleChildScrollView(
child: Container(
padding: const EdgeInsets.all(
StyleConstants.linear8,
padding: const EdgeInsets.only(
left: StyleConstants.linear8,
top: StyleConstants.linear8,
right: StyleConstants.linear8,
bottom: StyleConstants.linear32,
),
child: Column(
mainAxisSize: MainAxisSize.min,
Expand All @@ -77,11 +83,6 @@ class AppDetailPageState extends State<AppDetailPage> {
),
),
const SizedBox(height: 20.0),
Text(
widget.pairing.peerMetadata!.name,
style: StyleConstants.subtitleText,
),
const SizedBox(height: 20.0),
Text(widget.pairing.peerMetadata!.url),
Text('Expires on: $expiryDate'),
const SizedBox(height: 20.0),
Expand Down
21 changes: 17 additions & 4 deletions example/wallet/lib/widgets/pairing_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,28 @@ class PairingItem extends StatelessWidget {
: const AssetImage('assets/images/default_icon.png'))
as ImageProvider<Object>,
),
title: Text(metadata.name),
title: Text(
metadata.name,
style: const TextStyle(color: Colors.white),
),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(metadata.url),
Text('Expires on: $expiryDate'),
Text(
metadata.url,
style: const TextStyle(color: Colors.white60),
),
Text(
'Expires on: $expiryDate',
style: const TextStyle(color: Colors.white60),
),
],
),
trailing: const Icon(Icons.arrow_forward_ios, size: 20.0),
trailing: const Icon(
Icons.arrow_forward_ios,
size: 20.0,
color: Colors.white60,
),
onTap: onTap,
);
}
Expand Down

0 comments on commit 4e0243e

Please sign in to comment.