Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
5.8 kB
1
Indexable
Never
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:provalue/core/common_widget/common_list_name_tile.dart';
import 'package:provalue/infrastructure/repository/provider.dart';
import 'package:provalue/presentation/view_model/details_list_page_provider.dart';

import '../../../core/utils/color_constants.dart';
import '../../../core/utils/icon_constants.dart';
import '../../../core/utils/strings.dart';

class DetailsListPage extends ConsumerStatefulWidget {
  const DetailsListPage({super.key});

  @override
  ConsumerState createState() => _DetailsListPageState();
}

class _DetailsListPageState extends ConsumerState<DetailsListPage> {
  late DetailsPageListProvider provider;

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
      var provider = ref.read(getDetailsListPageProvider);
      provider.onInit(context);
    });
  }

  @override
  Widget build(BuildContext context) {
    provider = ref.watch(getDetailsListPageProvider);

    return buildListBody(context);
  }

  Widget buildListBody(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Padding(
            padding: const EdgeInsets.fromLTRB(0, 0, 150, 0),
            child: buildVideo(context),
          ),
          const SizedBox(height: 20),
          buildName(context),
          const SizedBox(height: 20),
          buildIndustryName(context),
          const SizedBox(height: 20),
          buildDescription(context),
          const SizedBox(height: 20),
          buildPrice(context),
        ],
      ),
    );
  }

  Widget buildCardAppBar(
      DetailsPageListProvider provider, BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          InkWell(
            onTap: () {},
            child: SvgPicture.asset(
              IconConstants.icEdit,
            ),
          ),
          const SizedBox(width: 20),
          InkWell(
            onTap: () {},
            child: SvgPicture.asset(
              IconConstants.icDelete,
            ),
          ),
        ],
      ),
    );
  }

  Column buildVideo(BuildContext context) {
    return Column(
      children: [
        ClipRRect(
            borderRadius: BorderRadius.circular(8.0),
            child: Image.asset(
              IconConstants.imgItem7,
              // scale: 3.5,
              height: 75.0,
              width: 100.0,
            )),
        const SizedBox(
          height: 6,
        ),
        Text(
          Strings.loremIpsumText,
          style: Theme.of(context).textTheme.bodyMedium?.copyWith(
              fontSize: 12, color: ColorConstants.textSecondaryColor),
        ),
      ],
    );
  }

  Widget buildName(BuildContext context) {
    return const ListNameTile(
      isIconPadding: true,
      title: Strings.listNameText,
      description: Strings.loremIpsumText,
      icon: IconConstants.createList,
    );
  }

  Widget buildIndustryName(BuildContext context) {
    return const ListNameTile(
      title: Strings.insuranceAgencyListText,
      description: Strings.loremIpsumText,
      icon: IconConstants.insuranceList,
    );
  }

  Widget buildDescription(BuildContext context) {
    return Row(
      mainAxisSize: MainAxisSize.max,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Padding(
          padding: const EdgeInsets.only(left: 4.0, top: 3.8),
          child: SvgPicture.asset(IconConstants.iconNotes),
        ),
        const SizedBox(
          width: 20,
        ),
        Expanded(
          child: RichText(
            text: TextSpan(
                text: Strings.descriptionDetailsText,
                style: Theme.of(context).textTheme.bodyMedium?.copyWith(
                      fontSize: 16,
                      color: ColorConstants.textSecondaryColor,
                    ),
                children: [
                  const WidgetSpan(
                      child: SizedBox(
                    width: 8,
                  )),
                  TextSpan(
                    text: Strings.loremText1,
                    style: Theme.of(context).textTheme.bodySmall?.copyWith(
                          fontSize: 16,
                          // color: ColorConstants.textPrimaryColor
                        ),
                  ),
                  TextSpan(
                    text: Strings.loremText2,
                    style: Theme.of(context)
                        .textTheme
                        .bodySmall
                        ?.copyWith(fontSize: 16, height: 1.4),
                  ),
                  TextSpan(
                    text: Strings.loremText3,
                    style: Theme.of(context)
                        .textTheme
                        .bodySmall
                        ?.copyWith(fontSize: 16, height: 1.4),
                  ),
                  TextSpan(
                    text: Strings.loremText4,
                    style: Theme.of(context)
                        .textTheme
                        .bodySmall
                        ?.copyWith(fontSize: 16, height: 1.4),
                  ),
                ]),
          ),
        ),
      ],
    );
  }

  Widget buildPrice(BuildContext context) {
    return const ListNameTile(
      colorChange: true,
      title: Strings.priceDetailsText,
      description: Strings.amountDetailsText,
      icon: IconConstants.icDollar,
    );
  }
}