// SPDX-FileCopyrightText: © 2025 Nøkken.io <nokken.io@proton.me>
// SPDX-License-Identifier: AGPL-3.0
//
// add_edit_oral_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';

/// Oral Subtype Section - Only shown for oral medications
class OralSubtypeSection extends StatelessWidget {
  final OralSubtype? subtype;
  final ValueChanged<OralSubtype> onSubtypeChanged;

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

  @override
  Widget build(BuildContext context) {
    return SharedWidgets.basicCard(
      context: context,
      title: 'Oral Medication Form',
      children: [
        DropdownWidgets.customDropdownButtonFormField<OralSubtype>(
          value: subtype ?? OralSubtype.tablets,
          decoration: AppTheme.defaultTextFieldDecoration.copyWith(),
          items: OralSubtype.values.map((type) {
            String displayName;
            switch (type) {
              case OralSubtype.tablets:
                displayName = 'Tablets';
                break;
              case OralSubtype.capsules:
                displayName = 'Capsules';
                break;
              case OralSubtype.drops:
                displayName = 'Drops';
                break;
            }

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