app/lib/screens/transactions.dart

66 lines
2.1 KiB
Dart
Raw Normal View History

2022-04-27 08:20:01 +02:00
import 'package:flutter/material.dart';
import 'package:nekoya_flutter/api/api.dart';
import 'package:nekoya_flutter/components/transaction_box.dart';
2022-05-12 16:47:08 +02:00
import 'package:nekoya_flutter/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 {
var session = await getSession();
var data = await getTransactions(session);
return data;
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>(
2022-05-12 17:10:28 +02:00
future: loadTransaction(),
2022-04-27 08:20:01 +02:00
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'],
);
}
);
}
return const Center(
child: CircularProgressIndicator(
color: Color(0xff8B0000),
),
);
}
)
);
}
}