import 'package:flutter/material.dart';
import 'package:grostore/configs/style_config.dart';
import 'package:grostore/custom_ui/BoxDecorations.dart';
import 'package:grostore/custom_ui/Button.dart';
import 'package:grostore/custom_ui/Image_view.dart';
import 'package:grostore/helpers/device_info_helper.dart';
import 'package:grostore/helpers/route.dart';
import 'package:grostore/models/order/orders_response.dart';
import 'package:grostore/screens/order/order_details.dart';


class OrderViewModel extends StatelessWidget {
  OrderViewModel({Key? key ,required this.orderInfo,required this.context}) : super(key: key);
  OrderInfo orderInfo;
  // int orderId;
  BuildContext context;

  @override
  Widget build(BuildContext context) {
    return  Container(
      width: getWidth(this.context),
      height: 100,
      padding: EdgeInsets.symmetric(horizontal: StyleConfig.padding),
      decoration: BoxDecorations.shadow(radius: 2),
      child: Button(
        onPressed: (){
          print("} ${orderInfo.id} {");
          MakeRoute.go(this.context, OrderDetails(code: orderInfo.group_id,));
        },
        child: Row(
          children: [
            Expanded(
              flex: 1,
              child: Image(image: AssetImage("assets/logos/logo_a.png"),)
            ),
            Expanded(
              flex:3,
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  SizedBox(
                      width: getWidth(this.context)*0.50,
                      child: Text("Buyurtma raqami: ${orderInfo.group_id}",style: StyleConfig.fs16,)),
                  // SizedBox(
                  //     width: getWidth(this.context)*0.50,
                  //     child: Text(orderInfo.item.product?.categories.first.name??"",style: StyleConfig.fs14fwNormal,)),
                  SizedBox(
                      width: getWidth(this.context)*0.50,
                      child: Text("Umumiy summa: ${orderInfo.item.totalPrice}",style: StyleConfig.fs14fwBold,)),
                  SizedBox(
                    width: getWidth(this.context)*0.50,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text("Buyurtma sanasi:",style: StyleConfig.fs12,maxLines: 1,),
                        Flexible(
                            flex: 1,
                            child: Text("${orderInfo.date.year}/0${orderInfo.date.day}/0${orderInfo.date.month}",style: StyleConfig.fs11,maxLines: 1,textAlign: TextAlign.right,)),
                      ],
                    ),
                  ),
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
