import 'package:flutter/material.dart';

import 'title_point.dart';

class Level2View extends StatelessWidget {
  const Level2View(
      {super.key,
      required this.level1,
      required this.level2,
      required this.level1Title,
      required this.level2Title,
      required this.level2SubTitle,
      this.level1Action});

  final Widget level1;
  final Widget level2;
  final Widget? level1Action;
  final String level1Title;
  final String level2Title;
  final Widget level2SubTitle;

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      height: double.infinity,
      margin: const EdgeInsets.all(20),
      padding: const EdgeInsets.fromLTRB(12, 17, 12, 17),
      decoration: BoxDecoration(
          color: Colors.white, borderRadius: BorderRadius.circular(16)),
      child: Row(
        children: [
          SizedBox(width: 260, height: double.infinity, child: left(context)),
          const VerticalDivider(
              width: 15, color: Color(0xffd8d8d8), thickness: 1),
          Expanded(child: right(context))
        ],
      ),
    );
  }

  TextStyle get titleStyle => const TextStyle(
      fontSize: 14.22, color: Color(0xff333333), fontWeight: FontWeight.w700);

  Widget left(BuildContext context) {
    return Column(
      children: [
        Row(
          children: [
            const Padding(padding: EdgeInsets.all(8), child: TitlePoint()),
            Text(level1Title, style: titleStyle),
            const Spacer(),
            level1Action ?? const SizedBox()
          ],
        ),
        const SizedBox(height: 20),
        Expanded(child: level1),
      ],
    );
  }

  Widget right(BuildContext context) {
    return Column(
      children: [
        Row(
          children: [
            const Padding(padding: EdgeInsets.all(8), child: TitlePoint()),
            Text(level2Title, style: titleStyle),
            Expanded(child: level2SubTitle),
          ],
        ),
        Expanded(
            child: Padding(padding: const EdgeInsets.all(18), child: level2))
      ],
    );
  }
}
