81 lines
2.1 KiB
Dart
81 lines
2.1 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;
|
|
bool loading = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
load();
|
|
}
|
|
|
|
load() async {
|
|
String result = await _channel.invokeMethod('init', <String, dynamic>{
|
|
'serverUrl': 'http://185.98.84.231:2000',
|
|
});
|
|
setState(() {
|
|
initValue = 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;
|
|
});
|
|
}
|
|
|
|
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: Center(
|
|
child: Column(
|
|
children: <Widget>[
|
|
Text('init: $initValue'),
|
|
Text('connection: $connectionValue'),
|
|
Text('auth: $authValue'),
|
|
RaisedButton(child: Text('Connect'), onPressed: connect),
|
|
RaisedButton(child: Text('Auth'), onPressed: auth),
|
|
RaisedButton(child: Text('Press'), onPressed: activity),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|