import 'package:driverapp/core/viewModels/orders_view_model.dart';
import 'package:driverapp/uitl/translations_delegate_base.dart';
import 'package:driverapp/widgets/order/order_info_card.dart';
import 'package:driverapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../base/base_view.dart';

class OrdersListScreen extends StatefulWidget {
  @override
  _OrdersListScreenState createState() => _OrdersListScreenState();
}

class _OrdersListScreenState extends State<OrdersListScreen> {
  @override
  Widget build(BuildContext context) {
    return BaseView<OrdersViewModel>(
      onModelReady: (model) => model.getPendingOrders(),
      builder: (BuildContext context, OrdersViewModel model, Widget child) =>
          AppScaffold(
        isShowAppBar: true,
        appBarTitle: TranslationBase.of(context).yourDeliveryQue,
        titleColor: Colors.black,
        body: Column(
          children: <Widget>[
            SizedBox(
              height: 20,
            ),
            Expanded(
              child: ListView.builder(
                shrinkWrap: true,
                scrollDirection: Axis.vertical,
                itemCount: model.orders == null ? 0 : model.orders.length,
                itemBuilder: (BuildContext context, int index) {
                  return Padding(
                    padding: EdgeInsets.symmetric(horizontal: 12.2),
                    child: OrderInfoCard(order: model.orders[index]),
                  );
                },
              ),
            ),
          ],
        ),
      ),
    );
  }
}
