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/views/widgets/my_scafold.dart';
import 'package:SEFER/views/widgets/mycircular.dart';

import '../../../controller/payment/driver_payment_controller.dart';

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

  @override
  Widget build(BuildContext context) {
    Get.put(DriverWalletHistoryController());
    return MyScafolld(
        title: 'Payment History'.tr,
        body: [
          GetBuilder<DriverWalletHistoryController>(
            builder: (controller) => controller.isLoading
                ? const MyCircularProgressIndicator()
                : 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['amount']) < 0
                                  ? AppColor.redColor.withOpacity(.4)
                                  : AppColor.greenColor.withOpacity(.4)),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              Text(
                                list['amount'],
                                style: AppStyle.title,
                              ),
                              Text(
                                list['created_at'],
                                style: AppStyle.title,
                              ),
                            ],
                          ),
                        ),
                      );
                    },
                  ),
          )
        ],
        isleading: true);
  }
}
