import 'package:cashier_reserve/common/base/ui.dart';
import 'package:cashier_reserve/common/channel/call_log_model.dart';
import 'package:cashier_reserve/home/reserve_view_model.dart';

class ReserveLeftContentView extends StatelessWidget {
  final ReserveViewModel provider;
  const ReserveLeftContentView({super.key, required this.provider});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Expanded(
            child: SizedBox(
              width: 430,
              child: ListView.builder(
                itemCount: provider.callLogs?.length ?? 0,
                itemBuilder: (context, index) {
                  return _buildCallRecordItem(context, provider.callLogs?[index]);
                },
              ),
            )),
        Container(
          padding: const EdgeInsets.fromLTRB(20, 10, 20, 15),
          child: InkWell(
            onTap: () {},
            child: Container(
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(5),
                color: const Color(0xff318AFE),
              ),
              width: 300,
              height: 36,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Image.asset(
                    'images/reserve/create.png',
                    width: 20,
                    height: 20,
                  ),
                  const SizedBox(
                    width: 5,
                  ),
                  const Text(
                    "创建订单",
                    style: TextStyle(color: Colors.white, fontSize: 14),
                  ),
                ],
              ),
            ),
          ),
        )
      ],
    );
  }

  /// _buildCallRecordItem 通话记录item
  Widget _buildCallRecordItem(BuildContext context, CallLogModel? model) {
    return Container(
      padding: const EdgeInsets.fromLTRB(15, 15, 15, 5),
      child: Column(
        children: [
          Row(
            children: [
              Column(
                children: [
                  Image.asset(
                    (model?.type ?? 0) == 3
                        ? "images/reserve/phone_fail.png"
                        : "images/reserve/phone_suc.png",
                    width: 24,
                    height: 24,
                  ),
                  const SizedBox(height: 2),
                  Text(
                    model?.time ?? "",
                    style:
                    const TextStyle(color: Color(0xff999999), fontSize: 12),
                  ),
                ],
              ),
              const SizedBox(width: 10),
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    model?.name ?? "未知电话",
                    style:
                    const TextStyle(color: Color(0xff333333), fontSize: 14),
                  ),
                  const SizedBox(height: 5),
                  Row(
                    children: [
                      Text(
                        model?.number ?? "",
                        style: const TextStyle(
                            color: Color(0xff333333), fontSize: 14),
                      ),
                      const SizedBox(
                        width: 15,
                      ),
                      const Text(
                        "已消费0单",
                        style:
                        TextStyle(color: Color(0xff333333), fontSize: 14),
                      ),
                      const SizedBox(
                        width: 15,
                      ),
                      const Text(
                        "已撤0单",
                        style:
                        TextStyle(color: Color(0xff333333), fontSize: 14),
                      ),
                    ],
                  ),
                ],
              ),
              const Expanded(child: SizedBox()),
              InkWell(
                onTap: () {},
                child: Container(
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(5),
                    border:
                    Border.all(color: const Color(0xff318AFE), width: 1),
                  ),
                  padding: const EdgeInsets.fromLTRB(20, 7, 20, 7),
                  child: const Text(
                    "处理",
                    style: TextStyle(color: Color(0xff318AFE), fontSize: 14),
                  ),
                ),
              )
            ],
          ),
          const SizedBox(
            height: 10,
          ),
          Container(
            height: 1,
            color: const Color(0xffededed),
          ),
        ],
      ),
    );
  }
}