diff --git a/Sources/iOS/App/Screens/OtherMenu/Settings/PushSettings/PushSettingsGroupNotifyTableView.swift b/Sources/iOS/App/Screens/OtherMenu/Settings/PushSettings/PushSettingsGroupNotifyTableView.swift new file mode 100644 index 000000000..8c06f86cb --- /dev/null +++ b/Sources/iOS/App/Screens/OtherMenu/Settings/PushSettings/PushSettingsGroupNotifyTableView.swift @@ -0,0 +1,58 @@ +// +// PushSettingsGroupNotifyTableViewController.swift +// iMast +// +// Created by rinsuki on 2018/09/18. +// +// ------------------------------------------------------------------------ +// +// Copyright 2017-2019 rinsuki and other contributors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import UIKit +import SwiftUI +import iMastiOSCore + +struct PushSettingsGroupNotifyTableView: View { + @AppStorage(defaults: .$groupNotifyAccounts) var groupNotifyAccounts + @AppStorage(defaults: .$groupNotifyTypeBoost) var groupBoost + @AppStorage(defaults: .$groupNotifyTypeFavourite) var groupFavourite + @AppStorage(defaults: .$groupNotifyTypeMention) var groupMention + @AppStorage(defaults: .$groupNotifyTypeFollow) var groupFollow + @AppStorage(defaults: .$groupNotifyTypeUnknown) var groupUnknown + + var body: some View { + Form { + Section { + Toggle(isOn: $groupNotifyAccounts) { + Text(L10n.Preferences.Push.Shared.GroupRules.byAccount) + } + } + Section { + Toggle(isOn: $groupBoost) { Text("ブースト") } + Toggle(isOn: $groupFavourite) { Text("お気に入り") } + Toggle(isOn: $groupMention) { Text("メンション") } + Toggle(isOn: $groupFollow) { Text("フォロー") } + Toggle(isOn: $groupUnknown) { Text("その他") } + } header: { + Text(L10n.Preferences.Push.Shared.GroupRules.ByType.title) + } footer: { + Text(L10n.Preferences.Push.Shared.GroupRules.ByType.description) + } + } + .navigationTitle(L10n.Preferences.Push.Shared.GroupRules.title) + .navigationBarTitleDisplayMode(.inline) + } +} diff --git a/Sources/iOS/App/Screens/OtherMenu/Settings/PushSettings/PushSettingsGroupNotifyTableViewController.swift b/Sources/iOS/App/Screens/OtherMenu/Settings/PushSettings/PushSettingsGroupNotifyTableViewController.swift deleted file mode 100644 index 37154575e..000000000 --- a/Sources/iOS/App/Screens/OtherMenu/Settings/PushSettings/PushSettingsGroupNotifyTableViewController.swift +++ /dev/null @@ -1,90 +0,0 @@ -// -// PushSettingsGroupNotifyTableViewController.swift -// iMast -// -// Created by rinsuki on 2018/09/18. -// -// ------------------------------------------------------------------------ -// -// Copyright 2017-2019 rinsuki and other contributors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -import UIKit -import Eureka -import iMastiOSCore - -class PushSettingsGroupNotifyTableViewController: FormViewController { - - init() { - super.init(style: .grouped) - } - - required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - override func viewDidLoad() { - super.viewDidLoad() - - // Do any additional setup after loading the view. - - self.title = L10n.Preferences.Push.Shared.GroupRules.title - - self.form.append { - Section { - SwitchRow { row in - row.title = L10n.Preferences.Push.Shared.GroupRules.byAccount - row.userDefaultsConnect(Defaults.$groupNotifyAccounts) - } - } - Section( - header: L10n.Preferences.Push.Shared.GroupRules.ByType.title, - footer: L10n.Preferences.Push.Shared.GroupRules.ByType.description - ) { - SwitchRow { row in - row.title = "ブースト" - row.userDefaultsConnect(Defaults.$groupNotifyTypeBoost) - } - SwitchRow { row in - row.title = "お気に入り" - row.userDefaultsConnect(Defaults.$groupNotifyTypeFavourite) - } - SwitchRow { row in - row.title = "メンション" - row.userDefaultsConnect(Defaults.$groupNotifyTypeMention) - } - SwitchRow { row in - row.title = "フォロー" - row.userDefaultsConnect(Defaults.$groupNotifyTypeFollow) - } - SwitchRow { row in - row.title = "その他" - row.userDefaultsConnect(Defaults.$groupNotifyTypeUnknown) - } - } - } - } - - /* - // MARK: - Navigation - - // In a storyboard-based application, you will often want to do a little preparation before navigation - override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - // Get the new view controller using segue.destination. - // Pass the selected object to the new view controller. - } - */ - -} diff --git a/Sources/iOS/App/Screens/OtherMenu/Settings/PushSettings/PushSettingsTableViewController.swift b/Sources/iOS/App/Screens/OtherMenu/Settings/PushSettings/PushSettingsTableViewController.swift index ba80e4b4e..7a2ea37d7 100644 --- a/Sources/iOS/App/Screens/OtherMenu/Settings/PushSettings/PushSettingsTableViewController.swift +++ b/Sources/iOS/App/Screens/OtherMenu/Settings/PushSettings/PushSettingsTableViewController.swift @@ -74,7 +74,7 @@ class PushSettingsTableViewController: FormViewController { cell.textLabel?.textAlignment = .left cell.accessoryType = .disclosureIndicator }.onCellSelection { (cell, row) in - self.navigationController?.pushViewController(PushSettingsGroupNotifyTableViewController(), animated: true) + self.navigationController?.pushViewController(UIHostingController(rootView: PushSettingsGroupNotifyTableView()), animated: true) } ButtonRow { row in row.title = L10n.Preferences.Push.Shared.CustomSounds.title diff --git a/iMast.xcodeproj/project.pbxproj b/iMast.xcodeproj/project.pbxproj index 34d4a3b14..cd87550d7 100644 --- a/iMast.xcodeproj/project.pbxproj +++ b/iMast.xcodeproj/project.pbxproj @@ -142,7 +142,7 @@ CE7ABB421FC5C1610087B387 /* ListsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE7ABB411FC5C1610087B387 /* ListsTableViewController.swift */; }; CE7B1646238A8B23006E899E /* HelpAndFeedbackTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE7B1645238A8B23006E899E /* HelpAndFeedbackTableViewController.swift */; }; CE7DBED021843141008727D4 /* SearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE7DBECF21843141008727D4 /* SearchViewController.swift */; }; - CE8209982150EC390064FC93 /* PushSettingsGroupNotifyTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE8209972150EC390064FC93 /* PushSettingsGroupNotifyTableViewController.swift */; }; + CE8209982150EC390064FC93 /* PushSettingsGroupNotifyTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE8209972150EC390064FC93 /* PushSettingsGroupNotifyTableView.swift */; }; CE83C85E2A74103900D97E3E /* CodableViewDescriptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE83C85D2A74103900D97E3E /* CodableViewDescriptor.swift */; }; CE83C85F2A74103900D97E3E /* CodableViewDescriptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE83C85D2A74103900D97E3E /* CodableViewDescriptor.swift */; }; CE84AB19209526C500A3C4D2 /* NSFWGuardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE84AB18209526C500A3C4D2 /* NSFWGuardView.swift */; }; @@ -787,7 +787,7 @@ CE7B1645238A8B23006E899E /* HelpAndFeedbackTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HelpAndFeedbackTableViewController.swift; sourceTree = ""; }; CE7DBECF21843141008727D4 /* SearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchViewController.swift; sourceTree = ""; }; CE818B90218570B800948309 /* ThirdpartyTrendTags.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThirdpartyTrendTags.swift; sourceTree = ""; }; - CE8209972150EC390064FC93 /* PushSettingsGroupNotifyTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PushSettingsGroupNotifyTableViewController.swift; sourceTree = ""; }; + CE8209972150EC390064FC93 /* PushSettingsGroupNotifyTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PushSettingsGroupNotifyTableView.swift; sourceTree = ""; }; CE83C85D2A74103900D97E3E /* CodableViewDescriptor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CodableViewDescriptor.swift; sourceTree = ""; }; CE84AB18209526C500A3C4D2 /* NSFWGuardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSFWGuardView.swift; sourceTree = ""; }; CE854B8A25D4C0AB00C30BD7 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Timeline.strings; sourceTree = ""; }; @@ -1496,7 +1496,7 @@ CE3DB68520FB07FE005CFD77 /* PushService.swift */, CECD756620FD92C1000D059A /* PushSettingsTableViewController.swift */, CE9D54A823BBA1D50030BF71 /* PushSettingsChangeSoundView.swift */, - CE8209972150EC390064FC93 /* PushSettingsGroupNotifyTableViewController.swift */, + CE8209972150EC390064FC93 /* PushSettingsGroupNotifyTableView.swift */, CE2D2AEF210C5CAF003B92B8 /* PushSettingsAccountTableViewController.swift */, CE11D6E12859190800F6A0AF /* OpenPushSettingsButton.swift */, ); @@ -3510,7 +3510,7 @@ 5D337B0226C952F600258CD1 /* UserProfileFieldViewController.swift in Sources */, CE7DBED021843141008727D4 /* SearchViewController.swift in Sources */, CE5895622240D2A50024FDBF /* AttachedMediaListViewController.swift in Sources */, - CE8209982150EC390064FC93 /* PushSettingsGroupNotifyTableViewController.swift in Sources */, + CE8209982150EC390064FC93 /* PushSettingsGroupNotifyTableView.swift in Sources */, CEF9C9E72AC139AF009ACFD9 /* OpenSafariButton.swift in Sources */, CEA528D528527DE70095EB1F /* SettingsView.swift in Sources */, CEF6DCC122EF2C030008B64D /* MastodonPostDetailBoostedUserViewController.swift in Sources */,