/// Password Visibility Provider
///
/// Simple state provider for toggling password visibility in login/register forms.
///
/// Uses Riverpod 3.0 with code generation for type-safe state management.
library;

import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'password_visibility_provider.g.dart';

/// Password Visibility State Provider
///
/// Manages the visibility state of password input fields.
/// Default state is false (password hidden).
///
/// Usage in login/register pages:
/// ```dart
/// class LoginPage extends ConsumerWidget {
///   @override
///   Widget build(BuildContext context, WidgetRef ref) {
///     final isPasswordVisible = ref.watch(passwordVisibilityProvider);
///
///     return TextField(
///       obscureText: !isPasswordVisible,
///       decoration: InputDecoration(
///         suffixIcon: IconButton(
///           icon: Icon(
///             isPasswordVisible ? Icons.visibility : Icons.visibility_off,
///           ),
///           onPressed: () {
///             ref.read(passwordVisibilityProvider.notifier).toggle();
///           },
///         ),
///       ),
///     );
///   }
/// }
/// ```
@riverpod
class PasswordVisibility extends _$PasswordVisibility {
  /// Initialize with password hidden (false)
  @override
  bool build() => false;

  /// Toggle password visibility
  ///
  /// Switches between showing and hiding the password.
  void toggle() {
    state = !state;
  }

  /// Show password
  ///
  /// Sets visibility to true (password visible).
  void show() {
    state = true;
  }

  /// Hide password
  ///
  /// Sets visibility to false (password hidden).
  void hide() {
    state = false;
  }
}

/// Confirm Password Visibility State Provider
///
/// Separate provider for confirm password field in registration forms.
/// This allows independent control of password and confirm password visibility.
///
/// Usage in registration page:
/// ```dart
/// final isConfirmPasswordVisible = ref.watch(confirmPasswordVisibilityProvider);
///
/// TextField(
///   obscureText: !isConfirmPasswordVisible,
///   decoration: InputDecoration(
///     labelText: 'Xác nhận mật khẩu',
///     suffixIcon: IconButton(
///       icon: Icon(
///         isConfirmPasswordVisible ? Icons.visibility : Icons.visibility_off,
///       ),
///       onPressed: () {
///         ref.read(confirmPasswordVisibilityProvider.notifier).toggle();
///       },
///     ),
///   ),
/// );
/// ```
@riverpod
class ConfirmPasswordVisibility extends _$ConfirmPasswordVisibility {
  /// Initialize with password hidden (false)
  @override
  bool build() => false;

  /// Toggle confirm password visibility
  void toggle() {
    state = !state;
  }

  /// Show confirm password
  void show() {
    state = true;
  }

  /// Hide confirm password
  void hide() {
    state = false;
  }
}
