Skip to content

Commit

Permalink
refactor in the overall structure
Browse files Browse the repository at this point in the history
  • Loading branch information
quetool committed Jan 10, 2025
1 parent 4cd7588 commit a8555a3
Show file tree
Hide file tree
Showing 14 changed files with 724 additions and 576 deletions.
2 changes: 1 addition & 1 deletion packages/reown_appkit/example/base/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class _MyHomePageState extends State<MyHomePage> {
appKit: _appKit,
enableAnalytics: true,
siweConfig: _siweConfig(linkMode),
featuresConfig: _featuresConfig(),
// featuresConfig: _featuresConfig(),
// requiredNamespaces: {},
// optionalNamespaces: {},
featuredWalletIds: _featuredWalletIds(),
Expand Down
191 changes: 100 additions & 91 deletions packages/reown_appkit/example/base/lib/pages/connect_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,113 +68,122 @@ class ConnectPageState extends State<ConnectPage> {
super.dispose();
}

Future<void> _refreshData() async {
await widget.appKitModal.reconnectRelay();
await widget.appKitModal.loadAccountData();
setState(() {});
}

@override
Widget build(BuildContext context) {
// Build the list of chain buttons, clear if the textnet changed
return ListView(
padding: const EdgeInsets.symmetric(
horizontal: StyleConstants.linear8,
),
children: <Widget>[
const SizedBox(height: StyleConstants.linear16),
Text(
widget.appKitModal.appKit!.metadata.name,
style: StyleConstants.subtitleText.copyWith(
color: ReownAppKitModalTheme.colorsOf(context).foreground100,
),
textAlign: TextAlign.center,
return RefreshIndicator(
onRefresh: () => _refreshData(),
child: ListView(
padding: const EdgeInsets.symmetric(
horizontal: StyleConstants.linear16,
),
const SizedBox(height: StyleConstants.linear24),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AppKitModalNetworkSelectButton(
appKit: widget.appKitModal,
),
const SizedBox.square(dimension: 8.0),
AppKitModalConnectButton(
appKit: widget.appKitModal,
children: <Widget>[
const SizedBox(height: StyleConstants.linear16),
Text(
widget.appKitModal.appKit!.metadata.name,
style: StyleConstants.subtitleText.copyWith(
color: ReownAppKitModalTheme.colorsOf(context).foreground100,
),
],
),
const SizedBox(height: StyleConstants.linear8),
Visibility(
visible: widget.appKitModal.isConnected,
child: Column(
textAlign: TextAlign.center,
),
const SizedBox(height: StyleConstants.linear24),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AppKitModalAccountButton(
appKitModal: widget.appKitModal,
AppKitModalNetworkSelectButton(
appKit: widget.appKitModal,
),
const SizedBox.square(dimension: 8.0),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AppKitModalBalanceButton(
appKitModal: widget.appKitModal,
onTap: widget.appKitModal.openNetworksView,
),
const SizedBox.square(dimension: 8.0),
AppKitModalAddressButton(
appKitModal: widget.appKitModal,
onTap: widget.appKitModal.openModalView,
),
],
AppKitModalConnectButton(
appKit: widget.appKitModal,
),
const SizedBox.square(dimension: 8.0),
...(_buildRequestButtons()),
],
),
),
const SizedBox(height: StyleConstants.linear8),
Visibility(
visible: !widget.appKitModal.isConnected,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Text(
'non-EVM\nSession Proposal',
textAlign: TextAlign.end,
style: TextStyle(
color: ReownAppKitModalTheme.colorsOf(context)
.foreground100,
fontWeight: !widget.linkMode
? FontWeight.bold
: FontWeight.normal,
const SizedBox(height: StyleConstants.linear8),
Visibility(
visible: widget.appKitModal.isConnected,
child: Column(
children: [
AppKitModalAccountButton(
appKitModal: widget.appKitModal,
),
const SizedBox.square(dimension: 8.0),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AppKitModalBalanceButton(
appKitModal: widget.appKitModal,
onTap: widget.appKitModal.openNetworksView,
),
const SizedBox.square(dimension: 8.0),
AppKitModalAddressButton(
appKitModal: widget.appKitModal,
onTap: widget.appKitModal.openModalView,
),
],
),
const SizedBox.square(dimension: 8.0),
...(_buildRequestButtons()),
],
),
),
const SizedBox(height: StyleConstants.linear8),
Visibility(
visible: !widget.appKitModal.isConnected,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Text(
'non-EVM\nSession Proposal',
textAlign: TextAlign.end,
style: TextStyle(
color: ReownAppKitModalTheme.colorsOf(context)
.foreground100,
fontWeight: !widget.linkMode
? FontWeight.bold
: FontWeight.normal,
),
),
),
),
Switch(
value: widget.linkMode,
onChanged: (value) {
widget.reinitialize(value);
},
),
Expanded(
child: Text(
'only EVM\nLink Mode',
style: TextStyle(
color: ReownAppKitModalTheme.colorsOf(context)
.foreground100,
fontWeight: widget.linkMode
? FontWeight.bold
: FontWeight.normal,
Switch(
value: widget.linkMode,
onChanged: (value) {
widget.reinitialize(value);
},
),
Expanded(
child: Text(
'only EVM\nLink Mode',
style: TextStyle(
color: ReownAppKitModalTheme.colorsOf(context)
.foreground100,
fontWeight: widget.linkMode
? FontWeight.bold
: FontWeight.normal,
),
),
),
),
],
),
],
],
),
],
),
),
),
const SizedBox(height: StyleConstants.linear16),
const Divider(height: 1.0),
const SizedBox(height: StyleConstants.linear8),
_FooterWidget(appKitModal: widget.appKitModal),
const SizedBox(height: StyleConstants.linear8),
],
const SizedBox(height: StyleConstants.linear16),
const Divider(height: 1.0),
const SizedBox(height: StyleConstants.linear8),
_FooterWidget(appKitModal: widget.appKitModal),
const SizedBox(height: StyleConstants.linear8),
],
),
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:convert';

import 'package:bs58/bs58.dart';
import 'package:eth_sig_util/util/utils.dart';
import 'package:reown_appkit/reown_appkit.dart';
import 'package:reown_appkit_dapp/utils/crypto/polkadot.dart';
Expand Down Expand Up @@ -89,11 +88,12 @@ Future<SessionRequestParams?> getParams(
],
);
case 'solana_signMessage':
final bytes = utf8.encode(testSignData);
final message = base58.encode(bytes);
return SessionRequestParams(
method: method,
params: {'pubkey': address, 'message': message},
params: {
'pubkey': address,
'message': 'Welcome to Flutter AppKit on Solana',
},
);
case 'solana_signTransaction':
// Create a connection to the devnet cluster.
Expand Down
1 change: 1 addition & 0 deletions packages/reown_appkit/example/modal/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies:
toastification: ^2.3.0

dependency_overrides:
pinenacl: ^0.6.0
# because of solana_web3 in reown_appkit
web_socket_channel: ^3.0.1

Expand Down
Loading

0 comments on commit a8555a3

Please sign in to comment.