/* * D8 — additions to `ui/settings/SettingsViewModel.kt`. * * 1. Add `private val feedback: FeedbackRepository` to the constructor's * @Inject parameter list (Hilt provides it automatically — see INTEGRATION.md * for why no module binding is required). * 2. Paste the state flow + methods below into the class body. * 3. Add the imports listed in INTEGRATION.md. * * Constructor becomes (illustrative — keep existing params): * * @HiltViewModel * class SettingsViewModel @Inject constructor( * private val vault: VaultRepository, * private val license: LicenseRepository, * private val feedback: FeedbackRepository, * @ApplicationContext private val appContext: Context, * ) : ViewModel() { */ private val _feedbackState = MutableStateFlow(FeedbackState.Idle) val feedbackState: StateFlow = _feedbackState.asStateFlow() fun sendFeedback(type: String, message: String) { if (_feedbackState.value is FeedbackState.Sending) return _feedbackState.value = FeedbackState.Sending viewModelScope.launch { _feedbackState.value = try { feedback.submit(type, message) FeedbackState.Sent } catch (e: Exception) { FeedbackState.Error("Couldn't send feedback — check your connection") } } } /** Reset to Idle when the Feedback card leaves the screen. */ fun resetFeedback() { _feedbackState.value = FeedbackState.Idle }