// SPDX-FileCopyrightText: © 2025 Nøkken.io <nokken.io@proton.me>
// SPDX-License-Identifier: AGPL-3.0
//
// add_edit_topical_subtype.dart
//
import 'package:flutter/material.dart';
import 'package:nokken/src/core/ui/widgets/shared_widgets.dart';
import 'package:nokken/src/core/ui/widgets/dropdown_widgets.dart';
import 'package:nokken/src/core/ui/theme/app_theme.dart';
import 'package:nokken/src/features/medication_tracker/models/medication.dart';

/// Topical Subtype Section - Only shown for topical medications
class TopicalSubtypeSection extends StatelessWidget {
  final TopicalSubtype? subtype;
  final ValueChanged<TopicalSubtype> onSubtypeChanged;

  const TopicalSubtypeSection({
    super.key,
    required this.subtype,
    required this.onSubtypeChanged,
  });

  @override
  Widget build(BuildContext context) {
    return SharedWidgets.basicCard(
      context: context,
      title: 'Topical Medication Form',
      children: [
        DropdownWidgets.customDropdownButtonFormField<TopicalSubtype>(
          value: subtype ?? TopicalSubtype.gel,
          decoration: AppTheme.defaultTextFieldDecoration.copyWith(),
          items: TopicalSubtype.values.map((type) {
            String displayName;
            switch (type) {
              case TopicalSubtype.gel:
                displayName = 'Gel';
                break;
              case TopicalSubtype.cream:
                displayName = 'Cream';
                break;
              case TopicalSubtype.spray:
                displayName = 'Spray';
                break;
            }

            return DropdownMenuItem<TopicalSubtype>(
              value: type,
              child: Text(displayName),
            );
          }).toList(),
          onChanged: (value) {
            if (value != null) {
              onSubtypeChanged(value);
            }
          },
        ),
      ],
    );
  }
}
