import 'package:flutter/cupertino.dart';
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/modules/cx_module/chat/chat_page.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';

class ChatRoomsPage extends StatefulWidget {
  ChatRoomsPage({Key? key}) : super(key: key);

  @override
  _ChatPageState createState() {
    return _ChatPageState();
  }
}

class _ChatPageState extends State<ChatRoomsPage> {
  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: AppColor.neutral100,
        appBar: const DefaultAppBar(title: "Chats"),
        body: SingleChildScrollView(
            padding: const EdgeInsets.all(16),
            child: ListView.separated(
                    shrinkWrap: true,
                    physics: const NeverScrollableScrollPhysics(),
                    padding: EdgeInsets.zero,
                    itemBuilder: (cxt, index) => Row(
                          children: [
                            Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                Text(
                                  "Request No. : 432212",
                                  maxLines: 1,
                                  overflow: TextOverflow.ellipsis,
                                  style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50, fontWeight: FontWeight.w600),
                                ),
                                Text(
                                  "Asset No. : HMG212",
                                  maxLines: 1,
                                  overflow: TextOverflow.ellipsis,
                                  style: AppTextStyles.bodyText2.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
                                ),
                                Text(
                                  "Request No. : 432212",
                                  maxLines: 1,
                                  overflow: TextOverflow.ellipsis,
                                  style: AppTextStyles.bodyText2.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
                                ),
                                6.height,
                                Text(
                                  "Mon 27 Oct, 2:00 PM",
                                  maxLines: 1,
                                  overflow: TextOverflow.ellipsis,
                                  style: AppTextStyles.bodyText2.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
                                ),
                              ],
                            ).expanded,
                            getStatus(),
                            8.width,
                            const Icon(
                              Icons.arrow_forward_ios_rounded,
                              size: 12,
                              color: AppColor.black20,
                            ),
                          ],
                        ).paddingOnly(top: 4, bottom: 4).onPress(() {
                          // Navigator.push(context, CupertinoPageRoute(builder: (context) => ChatPage()));
                          return;
                        }),
                    separatorBuilder: (cxt, index) => const Divider().defaultStyle(context),
                    itemCount: 10)
                .toShadowContainer(context, borderRadius: 20, showShadow: false, padding: 12)));
  }

  Widget getStatus() {
    Color color = const Color(0xff3B755C);
    return Container(
      padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
      decoration: BoxDecoration(
        color: const Color(0xff62BE96).withOpacity(.6),
        borderRadius: BorderRadius.circular(4),
      ),
      child: Text(
        "In Progress",
        maxLines: 1,
        style: AppTextStyles.tinyFont2.copyWith(color: color),
      ),
    );
  }
}
