import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:SEFER/constant/colors.dart';
import 'package:SEFER/constant/style.dart';
import 'package:SEFER/controller/payment/passenger_wallet_history_controller.dart';
import 'package:SEFER/views/widgets/my_scafold.dart';
import 'package:SEFER/views/widgets/mycircular.dart';

class PaymentHistoryPassengerPage extends StatelessWidget {
  const PaymentHistoryPassengerPage({super.key});

  @override
  Widget build(BuildContext context) {
    Get.put(PassengerWalletHistoryController());
    return MyScafolld(
        title: 'Payment History'.tr,
        body: [
          GetBuilder<PassengerWalletHistoryController>(
            builder: (controller) => controller.isLoading
                ? const MyCircularProgressIndicator()
                : controller.archive.isEmpty
                    ? Center(
                        child: Text(
                          'No wallet record found'.tr,
                          style: AppStyle.title,
                        ),
                      )
                    : ListView.builder(
                        itemCount: controller.archive.length,
                        itemBuilder: (BuildContext context, int index) {
                          var list = controller.archive[index];
                          return Padding(
                            padding: const EdgeInsets.all(4),
                            child: Container(
                              decoration: BoxDecoration(
                                  color: double.parse(list['balance']) < 0
                                      ? AppColor.redColor.withOpacity(.4)
                                      : AppColor.greenColor.withOpacity(.4)),
                              child: Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: [
                                  Text(
                                    list['balance'],
                                    style: AppStyle.title,
                                  ),
                                  Text(
                                    list['created_at'],
                                    style: AppStyle.title,
                                  ),
                                ],
                              ),
                            ),
                          );
                        },
                      ),
          )
        ],
        isleading: true);
  }
}
