2
2
mirror of https://github.com/mastodon/mastodon-ios synced 2025-04-11 22:58:02 +02:00

Begin implementing PrivacySafetyViewController (IOS-168)

This commit is contained in:
Marcus Kida 2024-05-28 17:13:25 +02:00
parent 84f445426a
commit cea13cb3de
No known key found for this signature in database
GPG Key ID: 19FF64E08013CA40
4 changed files with 96 additions and 1 deletions

View File

@ -21,6 +21,8 @@
0FB3D33825E6401400AAD544 /* PickServerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FB3D33725E6401400AAD544 /* PickServerCell.swift */; };
164F0EBC267D4FE400249499 /* BoopSound.caf in Resources */ = {isa = PBXBuildFile; fileRef = 164F0EBB267D4FE400249499 /* BoopSound.caf */; };
27D701F5292FC2D60031BCBB /* DataSourceFacade+URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27D701F4292FC2D60031BCBB /* DataSourceFacade+URL.swift */; };
2A0BF97F2C0622AA004A1E29 /* PrivacySafetyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A0BF97E2C0622AA004A1E29 /* PrivacySafetyViewController.swift */; };
2A0BF9812C06252A004A1E29 /* PrivacySafetyViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A0BF9802C06252A004A1E29 /* PrivacySafetyViewModel.swift */; };
2A1BF99529F7E68400FA1BA5 /* DataSourceFacade+UserView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A1BF99429F7E68400FA1BA5 /* DataSourceFacade+UserView.swift */; };
2A1FE47C2938BB2600784BF1 /* FollowedTagsViewModel+DiffableDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A1FE47B2938BB2600784BF1 /* FollowedTagsViewModel+DiffableDataSource.swift */; };
2A1FE47E2938C11200784BF1 /* Collection+IsNotEmpty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A1FE47D2938C11200784BF1 /* Collection+IsNotEmpty.swift */; };
@ -622,6 +624,8 @@
0FB3D33725E6401400AAD544 /* PickServerCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickServerCell.swift; sourceTree = "<group>"; };
164F0EBB267D4FE400249499 /* BoopSound.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = BoopSound.caf; sourceTree = "<group>"; };
27D701F4292FC2D60031BCBB /* DataSourceFacade+URL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DataSourceFacade+URL.swift"; sourceTree = "<group>"; };
2A0BF97E2C0622AA004A1E29 /* PrivacySafetyViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacySafetyViewController.swift; sourceTree = "<group>"; };
2A0BF9802C06252A004A1E29 /* PrivacySafetyViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacySafetyViewModel.swift; sourceTree = "<group>"; };
2A1BF99429F7E68400FA1BA5 /* DataSourceFacade+UserView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DataSourceFacade+UserView.swift"; sourceTree = "<group>"; };
2A1FE47B2938BB2600784BF1 /* FollowedTagsViewModel+DiffableDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FollowedTagsViewModel+DiffableDataSource.swift"; sourceTree = "<group>"; };
2A1FE47D2938C11200784BF1 /* Collection+IsNotEmpty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Collection+IsNotEmpty.swift"; sourceTree = "<group>"; };
@ -1372,6 +1376,15 @@
path = CollectionViewCell;
sourceTree = "<group>";
};
2A0BF97D2C062278004A1E29 /* Privacy and Safety */ = {
isa = PBXGroup;
children = (
2A0BF97E2C0622AA004A1E29 /* PrivacySafetyViewController.swift */,
2A0BF9802C06252A004A1E29 /* PrivacySafetyViewModel.swift */,
);
path = "Privacy and Safety";
sourceTree = "<group>";
};
2A506CF2292CD83B00059C37 /* FollowedTags */ = {
isa = PBXGroup;
children = (
@ -1686,6 +1699,7 @@
D8F916FF2A4AD898008A5370 /* Settings Overview */,
D8F917042A4B0657008A5370 /* General Settings */,
D81D12432A4E181C005009D4 /* Notification Settings */,
2A0BF97D2C062278004A1E29 /* Privacy and Safety */,
D80911062AC4BFD100EB4D15 /* Server Details */,
D8F917092A4B2AFF008A5370 /* About Mastodon */,
D8318A7F2A4466D300C0FB73 /* SettingsCoordinator.swift */,
@ -3534,6 +3548,7 @@
2DAC9E3E262FC2400062E1A6 /* SuggestionAccountViewModel.swift in Sources */,
DB603113279EBEBA00A935FE /* DataSourceFacade+Block.swift in Sources */,
DB63F777279A9A2A00455B82 /* NotificationView+Configuration.swift in Sources */,
2A0BF9812C06252A004A1E29 /* PrivacySafetyViewModel.swift in Sources */,
DB029E95266A20430062874E /* MastodonAuthenticationController.swift in Sources */,
DB6180DD263918E30018D199 /* MediaPreviewViewController.swift in Sources */,
DBE3CDEC261C6B2900430CC6 /* FavoriteViewController.swift in Sources */,
@ -3728,6 +3743,7 @@
D809907C294D25510050219F /* PrivacyViewModel.swift in Sources */,
D8318A862A4468C700C0FB73 /* SettingsViewController.swift in Sources */,
DB5B549A2833A60400DEF8B2 /* FamiliarFollowersViewController.swift in Sources */,
2A0BF97F2C0622AA004A1E29 /* PrivacySafetyViewController.swift in Sources */,
DB3E6FE22806A50100B035AE /* DiscoveryHashtagsViewModel+Diffable.swift in Sources */,
DB427DD625BAA00100D1B89D /* AppDelegate.swift in Sources */,
DB0FCB822796AC78006C02E2 /* UserTimelineViewController+DataSourceProvider.swift in Sources */,

View File

@ -0,0 +1,67 @@
// Copyright © 2024 Mastodon gGmbH. All rights reserved.
import UIKit
import SwiftUI
import MastodonSDK
import MastodonCore
import MastodonLocalization
import MastodonAsset
final class PrivacySafetyViewController: UIHostingController<PrivacySafetyView>, NeedsDependency {
weak var context: AppContext!
weak var coordinator: SceneCoordinator!
init(context: AppContext, coordinator: SceneCoordinator) {
self.context = context
self.coordinator = coordinator
super.init(rootView: PrivacySafetyView(viewModel: PrivacySafetyViewModel()))
}
@MainActor required dynamic init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
title = L10n.Scene.Settings.PrivacySafety.title
}
}
struct PrivacySafetyView: View {
@StateObject var viewModel: PrivacySafetyViewModel
var body: some View {
Form {
Section(L10n.Scene.Settings.PrivacySafety.Preset.title) {
CheckableButton(text: L10n.Scene.Settings.PrivacySafety.Preset.openAndPublic, isChecked: viewModel.preset == .openPublic, action: {
viewModel.preset = .openPublic
})
CheckableButton(text: L10n.Scene.Settings.PrivacySafety.Preset.privateAndRestricted, isChecked: viewModel.preset == .privateRestricted, action: {
viewModel.preset = .privateRestricted
})
CheckableButton(text: L10n.Scene.Settings.PrivacySafety.Preset.custom, isChecked: viewModel.preset == .custom, action: {
viewModel.preset = .custom
})
}
}
}
}
private struct CheckableButton: View {
let text: String
let isChecked: Bool
let action: () -> Void
var body: some View {
Button(action: action) {
HStack {
Text(text)
Spacer()
if isChecked {
Image(systemName: "checkmark")
.foregroundStyle(Asset.Colors.Brand.blurple.swiftUIColor)
}
}
}
}
}

View File

@ -0,0 +1,11 @@
// Copyright © 2024 Mastodon gGmbH. All rights reserved.
import Foundation
class PrivacySafetyViewModel: ObservableObject {
enum Preset {
case openPublic, privateRestricted, custom
}
@Published var preset: Preset = .openPublic
}

View File

@ -72,7 +72,8 @@ extension SettingsCoordinator: SettingsViewControllerDelegate {
navigationController.pushViewController(notificationViewController, animated: true)
case .privacySafety:
break
let privacySafetyViewController = PrivacySafetyViewController(context: appContext, coordinator: sceneCoordinator)
navigationController.pushViewController(privacySafetyViewController, animated: true)
case .serverDetails(let domain):
let serverDetailsViewController = ServerDetailsViewController(domain: domain, appContext: appContext, authContext: authContext, sceneCoordinator: sceneCoordinator)
serverDetailsViewController.delegate = self