176 lines
5.0 KiB
Dart
176 lines
5.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
class BankView extends StatefulWidget {
|
|
BankView();
|
|
|
|
@override
|
|
_BankViewState createState() => _BankViewState();
|
|
}
|
|
|
|
class _BankViewState extends State<BankView> {
|
|
static const MethodChannel _channel =
|
|
MethodChannel('channel:com.amanKassa/bank');
|
|
static const MethodChannel _activity =
|
|
MethodChannel('channel:com.amanKassa/activity');
|
|
String initValue;
|
|
String connectionValue;
|
|
String authValue;
|
|
String payValue;
|
|
String cancelValue;
|
|
String shutdownValue;
|
|
String versionValue;
|
|
bool loading = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
//load();
|
|
}
|
|
|
|
initialize() async {
|
|
String result = await _channel.invokeMethod('init', <String, dynamic>{
|
|
'serverUrl': 'http://185.98.84.231:2000',
|
|
});
|
|
setState(() {
|
|
initValue = result ?? 'none';
|
|
});
|
|
}
|
|
|
|
version() async {
|
|
String result = await _channel.invokeMethod('version');
|
|
setState(() {
|
|
versionValue = result ?? 'none';
|
|
});
|
|
}
|
|
|
|
connect() async {
|
|
String result = await _channel.invokeMethod("connection");
|
|
setState(() {
|
|
connectionValue = result;
|
|
});
|
|
}
|
|
|
|
auth() async {
|
|
String result = await _channel.invokeMethod("auth",
|
|
<String, dynamic>{'login': 'uvaissov@gmail.com', 'password': '1234'});
|
|
setState(() {
|
|
authValue = result;
|
|
});
|
|
}
|
|
|
|
pay() async {
|
|
String result;
|
|
try {
|
|
result =
|
|
await _channel.invokeMethod("pay", <String, dynamic>{'amount': 100});
|
|
} catch (e) {
|
|
result = (e.toString());
|
|
}
|
|
setState(() {
|
|
payValue = result;
|
|
});
|
|
}
|
|
|
|
cancel() async {
|
|
String result;
|
|
try {
|
|
result =
|
|
await _channel.invokeMethod("cancel");
|
|
} catch (e) {
|
|
result = (e.toString());
|
|
}
|
|
setState(() {
|
|
cancelValue = result;
|
|
});
|
|
}
|
|
|
|
shutdown() async {
|
|
String result;
|
|
try {
|
|
result =
|
|
await _channel.invokeMethod("shutdown");
|
|
} catch (e) {
|
|
result = (e.toString());
|
|
}
|
|
setState(() {
|
|
shutdownValue = result;
|
|
});
|
|
}
|
|
|
|
activity() async {
|
|
String result = await _activity.invokeMethod("start");
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
centerTitle: true,
|
|
title: Text('Банковская страница'),
|
|
),
|
|
body: loading
|
|
? Container(child: Center(child: CircularProgressIndicator()))
|
|
: SingleChildScrollView(
|
|
child: Container(
|
|
margin: const EdgeInsets.symmetric(horizontal: 14.0),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
RaisedButton(
|
|
child: Text('Activity m4Bank'), onPressed: activity),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: <Widget>[
|
|
Text('version: $versionValue'),
|
|
RaisedButton(
|
|
child: Text('Version'), onPressed: version),
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: <Widget>[
|
|
Text('init: $initValue'),
|
|
RaisedButton(
|
|
child: Text('Init'), onPressed: initialize),
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: <Widget>[
|
|
Text('connection: $connectionValue'),
|
|
RaisedButton(
|
|
child: Text('Connect'), onPressed: connect),
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: <Widget>[
|
|
Text('auth: $authValue'),
|
|
RaisedButton(child: Text('Auth'), onPressed: auth),
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: <Widget>[
|
|
Text('cancel: $cancelValue'),
|
|
RaisedButton(child: Text('Cancel'), onPressed: cancel),
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: <Widget>[
|
|
Text('shutdown: $shutdownValue'),
|
|
RaisedButton(child: Text('Shutdown'), onPressed: shutdown),
|
|
],
|
|
),
|
|
Text('pay: $payValue'),
|
|
RaisedButton(child: Text('Payment'), onPressed: pay),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|