Merge redesign part 4.

M committed Sep 9, 2020 at 17:13 UTC 16fbd9250dc55724efaab678530a1ea5d108e88f
3 files changed +32 -30
lib/bitcoin/electrum.dart
+20 -4
@@ -6,6 +6,16 @@ import 'package:cake_wallet/bitcoin/script_hash.dart';
6 import 'package:flutter/foundation.dart';
7 import 'package:rxdart/rxdart.dart';
8
9 +class UriParseException implements Exception {
10 + UriParseException(this.uri);
11 +
12 + final String uri;
13 +
14 + @override
15 + String toString() =>
16 + 'Cannot parse host and port from uri. Invalid uri format. Uri: $uri';
17 +}
18 +
19 String jsonrpcparams(List<Object> params) {
20 final _params = params?.map((val) => '"${val.toString()}"')?.join(',');
21 return '[$_params]';
@@ -40,9 +50,14 @@ class ElectrumClient {
50 Timer _aliveTimer;
51
52 Future<void> connectToUri(String uri) async {
43 - final _uri = Uri.parse(uri);
44 - final host = _uri.scheme;
45 - final port = int.parse(_uri.path);
53 + final splittedUri = uri.split(':');
54 +
55 + if (splittedUri.length != 2) {
56 + throw UriParseException(uri);
57 + }
58 +
59 + final host = splittedUri.first;
60 + final port = int.parse(splittedUri.last);
61 await connect(host: host, port: port);
62 }
63
@@ -51,7 +66,8 @@ class ElectrumClient {
66 await socket?.close();
67 } catch (_) {}
68
54 - socket = await SecureSocket.connect(host, port, timeout: connectionTimeout);
69 + socket = await SecureSocket.connect(host, port,
70 + timeout: connectionTimeout, onBadCertificate: (_) => true);
71 _setIsConnected(true);
72
73 socket.listen((Uint8List event) {
lib/src/screens/dashboard/dashboard_page.dart
+3 -12
@@ -88,9 +88,7 @@ class DashboardPage extends BasePage {
88 child: PageView.builder(
89 controller: controller,
90 itemCount: pages.length,
91 - itemBuilder: (context, index) {
92 - return pages[index];
93 - })),
91 + itemBuilder: (context, index) => pages[index])),
92 Padding(
93 padding: EdgeInsets.only(bottom: 24),
94 child: SmoothPageIndicator(
@@ -106,8 +104,9 @@ class DashboardPage extends BasePage {
104 )),
105 Container(
106 width: double.infinity,
109 - padding: EdgeInsets.only(left: 45, right: 45, bottom: 24),
107 + padding: EdgeInsets.only(left: 44, right: 0, bottom: 24),
108 child: Row(
109 + mainAxisAlignment: MainAxisAlignment.spaceBetween,
110 children: <Widget>[
111 Flexible(
112 child: ActionButton(
@@ -122,14 +121,6 @@ class DashboardPage extends BasePage {
121 image: exchangeImage,
122 title: S.of(context).exchange,
123 route: Routes.exchange),
125 - ),
126 - Flexible(
127 - child: ActionButton(
128 - image: receiveImage,
129 - title: S.of(context).receive,
130 - route: Routes.receive,
131 - alignment: Alignment.centerRight,
132 - ),
124 )
125 ],
126 ),
lib/src/screens/dashboard/widgets/action_button.dart
+9 -14
@@ -1,12 +1,11 @@
1 import 'package:flutter/material.dart';
2
3 -class ActionButton extends StatelessWidget{
4 - ActionButton({
5 - @required this.image,
6 - @required this.title,
7 - @required this.route,
8 - this.alignment = Alignment.center
9 - });
3 +class ActionButton extends StatelessWidget {
4 + ActionButton(
5 + {@required this.image,
6 + @required this.title,
7 + @required this.route,
8 + this.alignment = Alignment.center});
9
10 final Image image;
11 final String title;
@@ -35,20 +34,16 @@ class ActionButton extends StatelessWidget{
34 width: 60,
35 alignment: Alignment.center,
36 decoration: BoxDecoration(
38 - color: Theme.of(context).buttonColor,
39 - shape: BoxShape.circle),
37 + color: Theme.of(context).buttonColor, shape: BoxShape.circle),
38 child: image,
39 ),
40 ),
41 Text(
42 title,
45 - style: TextStyle(
46 - fontSize: 14,
47 - color: Colors.white
48 - ),
43 + style: TextStyle(fontSize: 14, color: Colors.white),
44 )
45 ],
46 ),
47 );
48 }
54 -}
\ No newline at end of file
49 +}