From 88f576d3d31f7552ee380c19a09de3a41e2c0602 Mon Sep 17 00:00:00 2001 From: Yusuke Hosonuma Date: Sun, 9 Aug 2020 20:26:05 +0900 Subject: [PATCH] refactor: --- iOS/View/SettingView.swift | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/iOS/View/SettingView.swift b/iOS/View/SettingView.swift index adcc9f4..495341c 100644 --- a/iOS/View/SettingView.swift +++ b/iOS/View/SettingView.swift @@ -18,7 +18,7 @@ struct SettingView: View { // MARK: Local Properties - @State private var isAlertPresented = false + @State private var isPresentedAlert = false @State private var isPresentedPhotoPicker = false @State private var selectedSize: Int? @@ -65,9 +65,9 @@ struct SettingView: View { Section { HCenter { - Button("Reset to Default", action: tapResetToDefault) + Button("Reset to Default", action: showResetAlert) .foregroundColor(.red) - .alert(isPresented: $isAlertPresented, content: resetAlert) + .alert(isPresented: $isPresentedAlert, content: resetAlert) } } } @@ -91,7 +91,8 @@ struct SettingView: View { Alert( title: Text("Do you really want to reset?"), primaryButton: .cancel(), - secondaryButton: .destructive(Text("Reset"), action: tapReset)) + secondaryButton: .destructive(Text("Reset"), action: setting.resetToDefault) + ) } // MARK: Actions @@ -104,12 +105,8 @@ struct SettingView: View { setting.backgroundImage = nil } - private func tapResetToDefault() { - isAlertPresented.toggle() - } - - private func tapReset() { - setting.resetToDefault() + private func showResetAlert() { + isPresentedAlert.toggle() } }