Merge redesign part 4.

This commit is contained in:
M 2020-09-09 17:13:44 +03:00
parent 7601b910be
commit 16fbd9250d
3 changed files with 32 additions and 30 deletions

View file

@ -6,6 +6,16 @@ import 'package:cake_wallet/bitcoin/script_hash.dart';
import 'package:flutter/foundation.dart';
import 'package:rxdart/rxdart.dart';
class UriParseException implements Exception {
UriParseException(this.uri);
final String uri;
@override
String toString() =>
'Cannot parse host and port from uri. Invalid uri format. Uri: $uri';
}
String jsonrpcparams(List<Object> params) {
final _params = params?.map((val) => '"${val.toString()}"')?.join(',');
return '[$_params]';
@ -40,9 +50,14 @@ class ElectrumClient {
Timer _aliveTimer;
Future<void> connectToUri(String uri) async {
final _uri = Uri.parse(uri);
final host = _uri.scheme;
final port = int.parse(_uri.path);
final splittedUri = uri.split(':');
if (splittedUri.length != 2) {
throw UriParseException(uri);
}
final host = splittedUri.first;
final port = int.parse(splittedUri.last);
await connect(host: host, port: port);
}
@ -51,7 +66,8 @@ class ElectrumClient {
await socket?.close();
} catch (_) {}
socket = await SecureSocket.connect(host, port, timeout: connectionTimeout);
socket = await SecureSocket.connect(host, port,
timeout: connectionTimeout, onBadCertificate: (_) => true);
_setIsConnected(true);
socket.listen((Uint8List event) {

View file

@ -88,9 +88,7 @@ class DashboardPage extends BasePage {
child: PageView.builder(
controller: controller,
itemCount: pages.length,
itemBuilder: (context, index) {
return pages[index];
})),
itemBuilder: (context, index) => pages[index])),
Padding(
padding: EdgeInsets.only(bottom: 24),
child: SmoothPageIndicator(
@ -106,8 +104,9 @@ class DashboardPage extends BasePage {
)),
Container(
width: double.infinity,
padding: EdgeInsets.only(left: 45, right: 45, bottom: 24),
padding: EdgeInsets.only(left: 44, right: 0, bottom: 24),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Flexible(
child: ActionButton(
@ -122,14 +121,6 @@ class DashboardPage extends BasePage {
image: exchangeImage,
title: S.of(context).exchange,
route: Routes.exchange),
),
Flexible(
child: ActionButton(
image: receiveImage,
title: S.of(context).receive,
route: Routes.receive,
alignment: Alignment.centerRight,
),
)
],
),

View file

@ -1,12 +1,11 @@
import 'package:flutter/material.dart';
class ActionButton extends StatelessWidget{
ActionButton({
@required this.image,
@required this.title,
@required this.route,
this.alignment = Alignment.center
});
class ActionButton extends StatelessWidget {
ActionButton(
{@required this.image,
@required this.title,
@required this.route,
this.alignment = Alignment.center});
final Image image;
final String title;
@ -35,20 +34,16 @@ class ActionButton extends StatelessWidget{
width: 60,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Theme.of(context).buttonColor,
shape: BoxShape.circle),
color: Theme.of(context).buttonColor, shape: BoxShape.circle),
child: image,
),
),
Text(
title,
style: TextStyle(
fontSize: 14,
color: Colors.white
),
style: TextStyle(fontSize: 14, color: Colors.white),
)
],
),
);
}
}
}