import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/service_request/pending_service_request_model.dart';
import 'package:test_sa/models/service_request/service_request.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
import 'package:test_sa/views/pages/user/requests/service_request_details.dart';

class PendingRequestBottomSheet extends StatelessWidget {
  PendingAssetServiceRequest pendingAssetServiceRequest;

  PendingRequestBottomSheet(this.pendingAssetServiceRequest, {Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: MediaQuery.of(context).size.height * .6,
      padding: const EdgeInsets.all(21),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          pendingAssetServiceRequest.headerMessage.heading5(context),
          "${pendingAssetServiceRequest.details.length} found".bodyText(context),
          8.height,
          ListView.separated(
              itemCount: pendingAssetServiceRequest.details.length,
              padding: EdgeInsets.only(top: 8),
              separatorBuilder: (cxt, index) => 12.height,
              itemBuilder: (cxt, index) => Container(
                    padding: EdgeInsets.symmetric(vertical: 16, horizontal: 8),
                    decoration: BoxDecoration(
                      color: Colors.grey[200],
                      borderRadius: BorderRadius.circular(16),
                    ),
                    child: Row(
                      children: [
                        Text(
                          pendingAssetServiceRequest.details[index].message.cleanupWhitespace?.capitalizeFirstOfEach ?? "",
                          style: Theme.of(context).textTheme.bodyLarge,
                        ).expanded,
                        Icon(Icons.arrow_forward_ios, size: 16)
                      ],
                    ),
                  ).onPress(() {
                    Navigator.of(context).push(MaterialPageRoute(
                        builder: (_) => ServiceRequestDetailsPage(
                              serviceRequest: ServiceRequest(id: pendingAssetServiceRequest.details[index].id.toString()),
                            )));
                  })).expanded,
          8.height,
          Row(
            children: [
              AppFilledButton(
                  label: context.translation.cancel,
                  textColor: AppColor.blueStatus(context),
                  buttonColor: AppColor.background(context),
                  maxWidth: true,
                  showBorder: true,
                  onPressed: () {
                    Navigator.pop(context, false);
                  }).expanded,
              16.width,
              AppFilledButton(
                  label: "Continue",
                  maxWidth: true,
                  onPressed: () {
                    Navigator.pop(context, true);
                  }).expanded,
            ],
          ),
        ],
      ),
    );
  }
}
