import 'package:elektronika/app/pages/order/details_screen.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../../../app.dart';

class OrderWidget extends StatelessWidget {
  final OrderModel model;
  final List<OrderItem> items;

  OrderWidget({required this.model, required this.items});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      margin: EdgeInsets.only(top: 8.h, bottom: 8.h),
      decoration: new BoxDecoration(
        color: ThemeColor.white,
        borderRadius: BorderRadius.circular(8),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            children: [
              Text(
                '№ ${model.id}',
                style: new TextStyle(
                  color: ThemeColor.mainColor,
                  fontWeight: FontWeight.w500,
                  fontSize: 14.sp,
                ),
              ),
              Spacer(),
              Text('${model.statusLabel}'),
            ],
          ),
          AppTheme.appColorDivider,
          Container(
            // color: Colors.yellow,
            padding: EdgeInsets.only(top: 8.h),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                ItemCardRowBuilder(title: 'purchase_date'.tr, content: model.createdAt),
                SizedBox(height: 12.h),
                ItemCardRowBuilder(
                  title: 'total_qty_ordered'.tr,
                  content: model.totalQtyOrdered.toString(),
                ),
                SizedBox(height: 12.h),
                ItemCardRowBuilder(title: 'price'.tr, content: model.formattedGrandTotal),
                SizedBox(height: 20.h),
                OutlinedButton(
                  child: Text('details'.tr),
                  style: OutlinedButton.styleFrom(
                    foregroundColor: ThemeColor.mainColor, fixedSize: Size(1.sw, 35.h),
                    backgroundColor: Colors.white,
                    side: BorderSide(color: ThemeColor.mainColor, width: 0.60),
                    shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(8))),
                  ),
                  onPressed: () {
                    debugPrint('Details');
                    Get.to(OrdersDetailsPage(items: items));
                  },
                ),
              ],
            ),
          ),
          SizedBox(height: 12.h),
        ],
      ),
    );
  }
}
