aman-kassa-flutter/lib/views/info_kkm/info_kkm_view.dart

121 lines
3.6 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import 'package:aman_kassa_flutter/core/entity/Voucher.dart';
import 'package:aman_kassa_flutter/core/locator.dart';
import 'package:aman_kassa_flutter/core/models/response.dart';
import 'package:aman_kassa_flutter/core/models/user.dart';
import 'package:aman_kassa_flutter/core/route_names.dart';
import 'package:aman_kassa_flutter/core/services/ApiService.dart';
import 'package:aman_kassa_flutter/core/services/navigator_service.dart';
import 'package:aman_kassa_flutter/redux/store.dart';
import 'package:aman_kassa_flutter/shared/app_colors.dart';
import 'package:aman_kassa_flutter/views/check/image_show_container.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
class InfoKkmView extends StatefulWidget {
InfoKkmView();
@override
_InfoKkmViewState createState() => _InfoKkmViewState();
}
class _InfoKkmViewState extends State<InfoKkmView> {
DateFormat dateFormat = DateFormat("dd.MM.yyyy HH:mm:ss");
ApiService _apiService = locator<ApiService>();
List<dynamic> data = [];
bool loading = false;
@override
void initState() {
super.initState();
load();
}
load() async {
setState(() {
loading = true;
});
User user = Redux.store.state.userState.user;
Response<dynamic> response = await _apiService.infoKkm(user.token);
if (response.operation) {
List<dynamic> list = [];
for (var key in response.body.keys) {
switch (key) {
case 'sn':
list.add({'key': 'Серийный номер', 'value': response.body[key]});
break;
case 'name':
list.add(
{'key': 'Наименование компании', 'value': response.body[key]});
break;
case 'biniin':
list.add({'key': 'ИИН/БИН', 'value': response.body[key]});
break;
case 'address':
list.add({'key': 'Адрес', 'value': response.body[key]});
break;
case 'kkmreg':
list.add({
'key': 'Регистрационный номер в органах НК',
'value': response.body[key]
});
break;
default:
}
}
setState(() {
data = list;
});
}
setState(() {
loading = false;
});
}
@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.all(8.0),
child: Table(
//defaultVerticalAlignment: TableCellVerticalAlignment.top,
children: data.map((e) {
return this.buildRow(e['key'], e['value']);
}).toList(),
),
),
),
);
}
TableRow buildRow(String key, String value) {
return TableRow(
children: <Widget>[
Container(
child: Text(
'$key :',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 15.0,
),
),
margin: EdgeInsets.only(bottom: 8.0),
),
Container(
child: Text(
value,
style: TextStyle(fontSize: 15.0),
),
margin: EdgeInsets.only(bottom: 8.0),
),
],
);
}
}