import 'package:comwell_key_app/routing/app_routes.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
import 'package:comwell_key_app/up_sales/models/addon_upgrade.dart';
import 'package:comwell_key_app/up_sales/models/room_upgrade.dart';
import 'package:comwell_key_app/utils/l10n_utils.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

class UpSalesContinueButton extends StatelessWidget {
  final List<AddOnUpgrade> selectedUpSales;
  final RoomUpgrade? selectedRoomUpgrade;
  final int extrasTotalPrice;
  const UpSalesContinueButton(
      {super.key,
      required this.selectedUpSales,
      required this.extrasTotalPrice,
      required this.selectedRoomUpgrade});

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    final isUpSalesEmpty =
        selectedUpSales.isEmpty && selectedRoomUpgrade == null;
    return Container(
      color: Theme.of(context).colorScheme.surface,
      child: Padding(
        padding: const EdgeInsets.only(
          left: 16.0,
          right: 16.0,
          top: 16.0,
          bottom: 40,
        ),
        child: ElevatedButton(
          onPressed: () {
            if (!isUpSalesEmpty) {
              context.push(AppRoutes.upSaleConfirmation, extra: [
                selectedUpSales,
                extrasTotalPrice,
                selectedRoomUpgrade
              ]);
            }
          },
          style: ButtonStyle(
            elevation: WidgetStateProperty.all(0),
            backgroundColor: WidgetStateProperty.all(
                isUpSalesEmpty ? Colors.grey : sandColor),
            foregroundColor: const WidgetStatePropertyAll(Colors.white),
          ),
          child: Padding(
              padding: const EdgeInsets.symmetric(vertical: 16.0),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text(
                    context.strings.generic_continue,
                    style: theme.textTheme.headlineSmall
                        ?.copyWith(color: Colors.white),
                  ),
                ],
              )),
        ),
      ),
    );
  }
}