import 'package:cims_apps/application/assets/path_assets.dart';
import 'package:cims_apps/application/component/subscribe/other_plan_view.dart';
import 'package:cims_apps/application/theme/color_palette.dart';
import 'package:cims_apps/core/route/route.dart';
import 'package:cims_apps/core/utils/size_config.dart';
import 'package:flutter/material.dart';

class GoalInvest {
  String icon;
  String title;

  GoalInvest(this.icon, this.title);
}

class GoalInvestingView extends StatelessWidget {
  final void Function(String) onListSelected;
  const GoalInvestingView({super.key, required this.onListSelected});

  @override
  Widget build(BuildContext context) {
    List<GoalInvest> listGoalInvest = [
      GoalInvest(PathAssets.iconToga, 'Education'),
      GoalInvest(PathAssets.iconCake, 'Marriage'),
      GoalInvest(PathAssets.iconHouse, 'Old age days'),
      GoalInvest(PathAssets.iconCreatePlan, 'Other Plan'),
    ];

    return Column(
      children:
        listGoalInvest.asMap().entries.map((e) {
          return Padding(
            padding: EdgeInsets.only(top: e.key != 0 ? 16 : 0),
            child: ListTile(
              onTap: () {
                if(e.value.title == 'Other Plan'){
                  routePush(
                    context,
                    page: OtherPlanView(
                      selectedPlan: (val) {
                        onListSelected(val);
                      },
                    )
                  );
                }else{
                  onListSelected(e.value.title);
                }
              },
              shape: RoundedRectangleBorder(
                side: BorderSide(color: ColorPalette.slate200),
                borderRadius: BorderRadius.circular(14)
              ),
              leading: Container(
                padding: EdgeInsets.all(4),
                decoration: BoxDecoration(
                  color: ColorPalette.blue200.withOpacity(0.5),
                  borderRadius: BorderRadius.circular(8)
                ),
                child: Image.asset(
                  e.value.icon,
                  width: SizeConfig.width * 0.07
                )
              ),
              contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 4),
              title: Text(e.value.title,
                style: TextStyle(
                  fontWeight: FontWeight.w600,
                  fontSize: 16,
                  color: ColorPalette.slate800
                ),
              ),
              trailing: Icon(Icons.chevron_right_rounded, color: ColorPalette.slate400),
            ),
          );
        }).toList()
    );
  }
}
