import 'package:hooks_riverpod/hooks_riverpod.dart';

import '../../../common/domain/metal_type.dart';
import '../data/profile_models.dart';

final profileSettingsControllerProvider =
    StateNotifierProvider<ProfileSettingsController, ProfileSettings>(
      (ref) => ProfileSettingsController(),
    );

class ProfileSettingsController extends StateNotifier<ProfileSettings> {
  ProfileSettingsController()
    : super(
        const ProfileSettings(
          amountHidden: false,
          recycleDiscounts: {
            MetalType.gold: 0.97,
            MetalType.platinum: 0.93,
            MetalType.silver: 0.88,
          },
          purityPresets: {
            '足金9999': 0.9999,
            '足金999': 0.999,
            'PT950': 0.95,
            '999银': 0.999,
          },
          priceColorMode: PriceColorMode.redUpGreenDown,
          mockLoggedIn: false,
        ),
      );

  void toggleAmountHidden() {
    state = state.copyWith(amountHidden: !state.amountHidden);
  }

  void setMockLoggedIn(bool value) {
    state = state.copyWith(mockLoggedIn: value);
  }

  void setPriceColorMode(PriceColorMode mode) {
    state = state.copyWith(priceColorMode: mode);
  }
}
