app/lib/screens/transactions.dart

68 lines
2.3 KiB
Dart
Raw Normal View History

2022-04-27 08:20:01 +02:00
import 'package:flutter/material.dart';
import 'package:nekoya_app/api/api.dart';
import 'package:nekoya_app/components/transaction_box.dart';
import 'package:nekoya_app/data/auth.dart';
2022-04-27 08:20:01 +02:00
class Transactions extends StatefulWidget {
const Transactions({Key? key}) : super(key: key);
@override
State<Transactions> createState() => _TransactionsState();
}
class _TransactionsState extends State<Transactions> {
2022-05-12 17:10:28 +02:00
Future<dynamic> loadTransaction() async {
2022-05-22 20:26:16 +02:00
try {
var session = await getSession();
var data = await getTransactions(session);
return data;
} catch (e) {
2022-05-22 20:26:16 +02:00
return [];
}
2022-05-12 16:47:08 +02:00
}
2022-04-27 08:20:01 +02:00
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xff1b1c1e),
appBar: AppBar(
title: const Text('Transactions'),
centerTitle: true,
backgroundColor: const Color(0xff212226),
),
body: FutureBuilder<dynamic>(
future: loadTransaction(),
builder: (context, snapshot) {
if (snapshot.hasData) {
var data = snapshot.data;
return ListView.builder(
itemCount: data!.length,
itemBuilder: (context, index) {
return TransactionBox(
orderId: data[index]['id'],
status: data[index]['status'],
firstName: data[index]['firstName'],
lastName: data[index]['lastName'],
phoneNumber: data[index]['phoneNumber'],
streetAddress1: data[index]['streetAddress1'],
district: data[index]['district'],
subDistrict: data[index]['subDistrict'],
province: data[index]['province'],
region: data[index]['region'],
postalCode: data[index]['postalCode'],
logistic: data[index]['logistic'],
data: data[index]['data'],
);
});
2022-04-27 08:20:01 +02:00
}
return const Center(
child: CircularProgressIndicator(
color: Color(0xff8B0000),
),
);
}));
2022-04-27 08:20:01 +02:00
}
}