Skip to content

Commit

Permalink
feat: add views preview in Debug menu - WPB-15523 (#2415)
Browse files Browse the repository at this point in the history
  • Loading branch information
El-Fitz authored Jan 24, 2025
1 parent 41d4a6c commit d2f7431
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 2 deletions.
15 changes: 13 additions & 2 deletions WireUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ let package = Package(
.library(name: "WireMoveToFolderUISupport", targets: ["WireMoveToFolderUISupport"]),
.library(name: "WireReusableUIComponents", targets: ["WireReusableUIComponents"]),
.library(name: "WireSettingsUI", targets: ["WireSettingsUI"]),
.library(name: "WireSidebarUI", targets: ["WireSidebarUI"])
.library(name: "WireSidebarUI", targets: ["WireSidebarUI"]),
.library(name: "WireViewsDebugUI", targets: ["WireViewsDebugUI"])
],
dependencies: [
.package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.1.0"),
Expand Down Expand Up @@ -89,7 +90,17 @@ let package = Package(
dependencies: ["WireFoundation"],
plugins: [.plugin(name: "SwiftGenPlugin", package: "WirePlugins")]
),
.testTarget(name: "WireSidebarUITests", dependencies: ["WireSidebarUI"])
.testTarget(name: "WireSidebarUITests", dependencies: ["WireSidebarUI"]),

.target(
name: "WireViewsDebugUI",
dependencies: [
"WireAuthenticationUI",
.product(name: "WireDomainPackage", package: "WireDomainPackage"),
"WireFoundation",
"WireReusableUIComponents"
]
)
]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import SwiftUI

package struct BackgroundView: View {
package init() {}

package var body: some View {
Image(ImageResource(name: "background", bundle: .module))
.resizable()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//
// Wire
// Copyright (C) 2025 Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//

import SwiftUI
import WireAuthenticationUI

public struct WireAuthenticationUIDebugView: View {

enum PresentationItem: String, Identifiable {
var id: String { rawValue }

case background
}

@State private var presentedItem: PresentationItem?

public init() {}

public var body: some View {
List {
Button(
action: { presentedItem = .background },
label: { Text("Background") }
)
}
.fullScreenCover(item: $presentedItem, content: { item in
switch item {
case .background:
fullscreenCover(content: { BackgroundView() })
}
})
}

@ViewBuilder
private func fullscreenCover(content: () -> some View) -> some View {
content()
.overlay {
HStack {
Spacer()
VStack {
Button(
action: { presentedItem = nil },
label: {
Image(systemName: "xmark.circle.fill")
.foregroundStyle(.white)
.font(.largeTitle)
}
)
.frame(width: 50, height: 50)
Spacer()
}
}
.padding(.top, 40)
.padding(.trailing, 20)
}
}
}

#Preview {
NavigationView {
WireAuthenticationUIDebugView()
}
}
7 changes: 7 additions & 0 deletions wire-ios/Wire-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@
669105C327397E6A00324115 /* NSAttributedString+DownTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 669105C227397E6900324115 /* NSAttributedString+DownTests.swift */; };
70355A7127AAD96E00F02C76 /* SecurityLevelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70355A7027AAD96E00F02C76 /* SecurityLevelView.swift */; };
764C478D2D1B32C100227531 /* MockSelfProfileViewsMonitorImplementation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 764C478C2D1B32BE00227531 /* MockSelfProfileViewsMonitorImplementation.swift */; };
76ACF8A22D4215E2001F48A1 /* WireViewsDebugUI in Frameworks */ = {isa = PBXBuildFile; productRef = 76ACF8A12D4215E2001F48A1 /* WireViewsDebugUI */; };
76D15E712CEFAE8A0059215D /* WireIndividualToTeamMigrationUI in Frameworks */ = {isa = PBXBuildFile; productRef = 76D15E702CEFAE8A0059215D /* WireIndividualToTeamMigrationUI */; };
7A702FB7286322D800004580 /* ConversationEncryptionProtocolCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A702FB6286322D800004580 /* ConversationEncryptionProtocolCell.swift */; };
7C0BB6E61FE682A200386A19 /* AccountSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C0BB6E41FE680F200386A19 /* AccountSelectionViewController.swift */; };
Expand Down Expand Up @@ -3883,6 +3884,7 @@
EEE25B3B29719C370008B894 /* WireLinkPreview.framework in Frameworks */,
407831AD2AC4636F005C2978 /* DifferenceKit in Frameworks */,
EEE25B4429719C950008B894 /* WireSystem.framework in Frameworks */,
76ACF8A22D4215E2001F48A1 /* WireViewsDebugUI in Frameworks */,
591B6E172C8B095B009F8A7B /* WireNotificationEngine.framework in Frameworks */,
59537D952CFFA11A00920B59 /* WireLogging in Frameworks */,
E9FBF3A62C47C23100C65DA8 /* FLAnimatedImage in Frameworks */,
Expand Down Expand Up @@ -8445,6 +8447,7 @@
76D15E702CEFAE8A0059215D /* WireIndividualToTeamMigrationUI */,
594906A42D0713C000238104 /* WireAnalytics */,
594341D62D08611700A6C0B5 /* WireCountly */,
76ACF8A12D4215E2001F48A1 /* WireViewsDebugUI */,
);
productName = "ZClient iOS";
productReference = 8F42C538199244A700288E4D /* Wire.app */;
Expand Down Expand Up @@ -11528,6 +11531,10 @@
isa = XCSwiftPackageProductDependency;
productName = WireMainNavigationUI;
};
76ACF8A12D4215E2001F48A1 /* WireViewsDebugUI */ = {
isa = XCSwiftPackageProductDependency;
productName = WireViewsDebugUI;
};
76D15E702CEFAE8A0059215D /* WireIndividualToTeamMigrationUI */ = {
isa = XCSwiftPackageProductDependency;
productName = WireIndividualToTeamMigrationUI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import WireDataModel
import WireRequestStrategy
import WireSyncEngine
import WireTransport
import WireViewsDebugUI

final class DeveloperToolsViewModel: ObservableObject {

Expand Down Expand Up @@ -138,6 +139,8 @@ final class DeveloperToolsViewModel: ObservableObject {
setupPushToken()

setupDatadog()

sections.append(debugViewSection)
}

// MARK: - Section Builders
Expand Down Expand Up @@ -289,6 +292,22 @@ final class DeveloperToolsViewModel: ObservableObject {
return sessionManager.canSwitchBackend() == nil
}

private lazy var debugViewSection: Section = {
let header = "Views"

let items: [Item] = [
.destination(DestinationItem(
title: "Authentication",
makeView: { AnyView(WireAuthenticationUIDebugView()) }
))
]

return Section(
header: header,
items: items
)
}()

// MARK: - Events

func handleEvent(_ event: Event) {
Expand Down

0 comments on commit d2f7431

Please sign in to comment.