Skip to content

Commit f475eb2

Browse files
authored
Merge pull request #47 from WalletConnect/chores/updates
Deps updates and minor changes
2 parents 4ed4ec8 + 9eddaa6 commit f475eb2

11 files changed

Lines changed: 93 additions & 89 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.1.17
2+
3+
- Dependency updates
4+
- Minor changes
5+
16
## 2.1.16
27

38
- Updated dependencies

analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ analyzer:
3939
- '**/generated_plugin_registrant.dart'
4040
errors:
4141
invalid_annotation_target: ignore
42+
4243
# Additional information about this file can be found at
4344
# https://dart.dev/guides/language/analysis-options

example/sign/lib/home_page.dart

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ import 'package:walletconnect_flutter_v2/walletconnect_flutter_v2.dart';
1010
import 'package:walletconnect_modal_flutter/walletconnect_modal_flutter.dart';
1111

1212
class MyHomePage extends StatefulWidget {
13-
const MyHomePage({
14-
super.key,
15-
required this.swapTheme,
16-
});
17-
18-
final void Function() swapTheme;
13+
const MyHomePage({super.key});
1914

2015
@override
2116
State<MyHomePage> createState() => _MyHomePageState();
@@ -89,41 +84,8 @@ class _MyHomePageState extends State<MyHomePage> {
8984
}
9085

9186
return Scaffold(
92-
body: Stack(
93-
children: [
94-
WCMPage(web3App: _web3App!),
95-
Positioned(
96-
bottom: 20,
97-
right: 20,
98-
child: Row(
99-
children: [
100-
_buildIconButton(
101-
Icons.theater_comedy_outlined,
102-
widget.swapTheme,
103-
),
104-
],
105-
),
106-
),
107-
],
108-
),
109-
);
110-
}
111-
112-
Widget _buildIconButton(IconData icon, void Function()? onPressed) {
113-
return Container(
114-
decoration: BoxDecoration(
115-
color: Colors.blue,
116-
borderRadius: BorderRadius.circular(
117-
48,
118-
),
119-
),
120-
child: IconButton(
121-
icon: Icon(
122-
icon,
123-
color: Colors.white,
124-
),
125-
iconSize: 24,
126-
onPressed: onPressed,
87+
body: WCMPage(
88+
web3App: _web3App!,
12789
),
12890
);
12991
}

example/sign/lib/main.dart

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class MyApp extends StatefulWidget {
1717
State<MyApp> createState() => _MyAppState();
1818
}
1919

20-
class _MyAppState extends State<MyApp> {
20+
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
2121
bool _isDark = true;
2222
List<Color> primaryColors = [
2323
WalletConnectModalThemeData.darkMode.primary100,
@@ -28,6 +28,14 @@ class _MyAppState extends State<MyApp> {
2828
@override
2929
void initState() {
3030
super.initState();
31+
WidgetsBinding.instance.addObserver(this);
32+
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
33+
setState(() {
34+
final platformDispatcher = View.of(context).platformDispatcher;
35+
final platformBrightness = platformDispatcher.platformBrightness;
36+
_isDark = platformBrightness == Brightness.dark;
37+
});
38+
});
3139

3240
SystemChrome.setPreferredOrientations([
3341
DeviceOrientation.landscapeRight,
@@ -39,6 +47,12 @@ class _MyAppState extends State<MyApp> {
3947
LoggerUtil.setLogLevel(Level.error);
4048
}
4149

50+
@override
51+
void dispose() {
52+
WidgetsBinding.instance.removeObserver(this);
53+
super.dispose();
54+
}
55+
4256
// This widget is the root of your application.
4357
@override
4458
Widget build(BuildContext context) {
@@ -57,16 +71,22 @@ class _MyAppState extends State<MyApp> {
5771
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
5872
useMaterial3: true,
5973
),
60-
home: SizedBox(
61-
width: double.infinity,
62-
child: MyHomePage(
63-
swapTheme: _swapTheme,
64-
),
65-
),
74+
home: const MyHomePage(),
6675
),
6776
);
6877
}
6978

79+
@override
80+
void didChangePlatformBrightness() {
81+
if (mounted) {
82+
final platformDispatcher = View.of(context).platformDispatcher;
83+
final platformBrightness = platformDispatcher.platformBrightness;
84+
_isDark = platformBrightness == Brightness.dark;
85+
_swapTheme();
86+
}
87+
super.didChangePlatformBrightness();
88+
}
89+
7090
void _swapTheme() {
7191
setState(() {
7292
_isDark = !_isDark;

example/sign/lib/pages/wcm_page.dart

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
44
import 'package:walletconnect_flutter_dapp/models/chain_metadata.dart';
55
import 'package:walletconnect_flutter_dapp/utils/constants.dart';
66
import 'package:walletconnect_flutter_dapp/utils/crypto/chain_data.dart';
7-
import 'package:walletconnect_flutter_dapp/utils/string_constants.dart';
87
import 'package:walletconnect_flutter_dapp/widgets/chain_button.dart';
98
import 'package:walletconnect_flutter_dapp/widgets/session_widget.dart';
109
import 'package:walletconnect_flutter_v2/walletconnect_flutter_v2.dart';
@@ -99,13 +98,32 @@ class _WCMPageState extends State<WCMPage> with SingleTickerProviderStateMixin {
9998

10099
Widget _buildWalletConnect() {
101100
// Build the list of chain button
102-
final List<ChainMetadata> chains = ChainData.chains;
101+
final List<Widget> evmChainButtons = [];
102+
final List<Widget> nonEvmChainButtons = [];
103103

104-
List<Widget> chainButtons = [];
104+
final evmChains = ChainData.chains.where((e) => e.type == ChainType.eip155);
105+
final nonEvmChains =
106+
ChainData.chains.where((e) => e.type != ChainType.eip155);
105107

106-
for (final ChainMetadata chain in chains) {
108+
for (final ChainMetadata chain in evmChains) {
107109
// Build the button
108-
chainButtons.add(
110+
evmChainButtons.add(
111+
ChainButton(
112+
chain: chain,
113+
onPressed: () {
114+
_selectChain(
115+
chain,
116+
// deselectOthers: true,
117+
);
118+
},
119+
selected: _selectedChains.contains(chain),
120+
),
121+
);
122+
}
123+
124+
for (final ChainMetadata chain in nonEvmChains) {
125+
// Build the button
126+
nonEvmChainButtons.add(
109127
ChainButton(
110128
chain: chain,
111129
onPressed: () {
@@ -123,37 +141,26 @@ class _WCMPageState extends State<WCMPage> with SingleTickerProviderStateMixin {
123141
appBar: AppBar(
124142
title: const Text('WalletConnectModal'),
125143
),
126-
body: Column(
127-
mainAxisAlignment: MainAxisAlignment.center,
128-
mainAxisSize: MainAxisSize.min,
129-
crossAxisAlignment: CrossAxisAlignment.center,
144+
body: ListView(
130145
children: [
146+
const Text('EVM Chains:', style: StyleConstants.buttonText),
147+
const SizedBox(height: StyleConstants.linear8),
148+
Wrap(
149+
spacing: 10.0,
150+
children: evmChainButtons,
151+
),
152+
const Divider(),
153+
const Text('Non EVM Chains:', style: StyleConstants.buttonText),
154+
Wrap(
155+
spacing: 10.0,
156+
children: nonEvmChainButtons,
157+
),
158+
const Divider(),
159+
const SizedBox(height: StyleConstants.linear8),
131160
WalletConnectModalConnect(
132161
service: _walletConnectModalService!,
133-
),
134-
// WalletConnectModalConnect(
135-
// service: _walletConnectModalService!,
136-
// width: double.infinity,
137-
// height: 100,
138-
// ),
139-
Expanded(
140-
child: Container(
141-
padding: const EdgeInsets.all(8.0),
142-
child: ListView(
143-
children: [
144-
const Text(
145-
StringConstants.selectChains,
146-
style: StyleConstants.subtitleText,
147-
textAlign: TextAlign.center,
148-
),
149-
const SizedBox(
150-
height: StyleConstants.linear24,
151-
),
152-
// _buildTestnetSwitch(),
153-
...chainButtons,
154-
],
155-
),
156-
),
162+
width: double.infinity,
163+
height: 50.0,
157164
),
158165
],
159166
),

example/sign/lib/utils/crypto/chain_data.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class ChainData {
106106
ChainMetadata(
107107
type: ChainType.eip155,
108108
color: Colors.yellow.shade600,
109-
chainName: 'Binance Smart Chain',
109+
chainName: 'Binance Chain',
110110
namespace: 'eip155:56',
111111
chainId: '56',
112112
chainIcon: '93564157-2e8e-4ce7-81df-b264dbee9b00',

example/sign/lib/widgets/chain_button.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ChainButton extends StatelessWidget {
1717
@override
1818
Widget build(BuildContext context) {
1919
return Container(
20-
width: double.infinity,
20+
width: (MediaQuery.of(context).size.width / 2) - 14,
2121
height: StyleConstants.linear48,
2222
margin: const EdgeInsets.symmetric(
2323
vertical: StyleConstants.linear8,
@@ -26,13 +26,13 @@ class ChainButton extends StatelessWidget {
2626
onPressed: onPressed,
2727
style: ButtonStyle(
2828
backgroundColor: MaterialStateProperty.all<Color>(
29-
Colors.white,
29+
selected ? Colors.grey.shade400 : Colors.white,
3030
),
3131
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
3232
RoundedRectangleBorder(
3333
side: BorderSide(
34-
color: chain.color,
35-
width: selected ? 6 : 2,
34+
color: selected ? Colors.grey.shade400 : chain.color,
35+
width: selected ? 4 : 2,
3636
),
3737
borderRadius: BorderRadius.circular(
3838
StyleConstants.linear8,

example/sign/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ packages:
10671067
path: "../.."
10681068
relative: true
10691069
source: path
1070-
version: "2.1.16"
1070+
version: "2.1.17"
10711071
watcher:
10721072
dependency: transitive
10731073
description:

lib/models/listings.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ part 'listings.g.dart';
66

77
@freezed
88
class WalletData with _$WalletData {
9+
// ignore: invalid_annotation_target
910
@JsonSerializable(includeIfNull: false)
1011
const factory WalletData({
1112
required Listing listing,
@@ -19,6 +20,7 @@ class WalletData with _$WalletData {
1920

2021
@freezed
2122
class ListingResponse with _$ListingResponse {
23+
// ignore: invalid_annotation_target
2224
@JsonSerializable(includeIfNull: false)
2325
const factory ListingResponse({
2426
required Map<String, Listing> listings,
@@ -31,6 +33,7 @@ class ListingResponse with _$ListingResponse {
3133

3234
@freezed
3335
class Listing with _$Listing {
36+
// ignore: invalid_annotation_target
3437
@JsonSerializable(includeIfNull: false, fieldRename: FieldRename.snake)
3538
const factory Listing({
3639
required String id,
@@ -49,6 +52,7 @@ class Listing with _$Listing {
4952

5053
@freezed
5154
class App with _$App {
55+
// ignore: invalid_annotation_target
5256
@JsonSerializable(includeIfNull: false, fieldRename: FieldRename.snake)
5357
const factory App({
5458
String? browser,
@@ -69,6 +73,7 @@ class App with _$App {
6973

7074
@freezed
7175
class Injected with _$Injected {
76+
// ignore: invalid_annotation_target
7277
@JsonSerializable(includeIfNull: false, fieldRename: FieldRename.snake)
7378
const factory Injected({
7479
required String injectedId,
@@ -81,6 +86,7 @@ class Injected with _$Injected {
8186

8287
@freezed
8388
class ListingParams with _$ListingParams {
89+
// ignore: invalid_annotation_target
8490
@JsonSerializable(includeIfNull: false)
8591
const factory ListingParams({
8692
int? page,

lib/version.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)