Skip to content

Commit

Permalink
Merge pull request #3793 from bbirman/add-connection
Browse files Browse the repository at this point in the history
Add labels and resizing to fields for accessibility on add connection…
  • Loading branch information
bbirman authored Jan 9, 2025
2 parents 9b870d5 + 6200322 commit 7889621
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 203 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
6938392723C82F38008E8E9A /* SFSDKNullURLCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 6938392523C82F38008E8E9A /* SFSDKNullURLCache.m */; };
693E623124A287DB0017B222 /* KeyValueEncryptedFileStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 693E623024A287DB0017B222 /* KeyValueEncryptedFileStore.swift */; };
693E623B24A29B6B0017B222 /* SFSDKKeyValueEncryptedFileStoreTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 693E623A24A29B6B0017B222 /* SFSDKKeyValueEncryptedFileStoreTests.m */; };
6941BE662D2F0E1B00CEC59B /* NewLoginHostView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6941BE652D2F0E1B00CEC59B /* NewLoginHostView.swift */; };
694490D025B8F4C4007747CD /* SFSDKWindowManager+Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 694490C725B8E567007747CD /* SFSDKWindowManager+Internal.h */; };
695E86A829EE24D0002BDEA6 /* SPConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 695E86A729EE24D0002BDEA6 /* SPConfig.swift */; };
695E86B929EF8D6E002BDEA6 /* SFSDKIDPAuthCodeLoginRequestCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 695E86B729EF8D6E002BDEA6 /* SFSDKIDPAuthCodeLoginRequestCommand.h */; };
Expand Down Expand Up @@ -399,8 +400,6 @@
E1C80CF01C5AEE31001B3A21 /* SFSDKLoginHostListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E1C80CE51C5AEE31001B3A21 /* SFSDKLoginHostListViewController.m */; };
E1C80CF11C5AEE31001B3A21 /* SFSDKLoginHostStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C80CE61C5AEE31001B3A21 /* SFSDKLoginHostStorage.h */; settings = {ATTRIBUTES = (Public, ); }; };
E1C80CF21C5AEE31001B3A21 /* SFSDKLoginHostStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = E1C80CE71C5AEE31001B3A21 /* SFSDKLoginHostStorage.m */; };
E1C80CF31C5AEE31001B3A21 /* SFSDKNewLoginHostViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C80CE81C5AEE31001B3A21 /* SFSDKNewLoginHostViewController.h */; };
E1C80CF41C5AEE31001B3A21 /* SFSDKNewLoginHostViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E1C80CE91C5AEE31001B3A21 /* SFSDKNewLoginHostViewController.m */; };
E1C80CF51C5AEE31001B3A21 /* SFSDKTextFieldTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C80CEA1C5AEE31001B3A21 /* SFSDKTextFieldTableViewCell.h */; };
E1C80CF61C5AEE31001B3A21 /* SFSDKTextFieldTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E1C80CEB1C5AEE31001B3A21 /* SFSDKTextFieldTableViewCell.m */; };
E1C80D081C5AF029001B3A21 /* SalesforceSDKAssets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E1C80D071C5AF029001B3A21 /* SalesforceSDKAssets.xcassets */; };
Expand Down Expand Up @@ -663,6 +662,7 @@
6938392523C82F38008E8E9A /* SFSDKNullURLCache.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SFSDKNullURLCache.m; sourceTree = "<group>"; };
693E623024A287DB0017B222 /* KeyValueEncryptedFileStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyValueEncryptedFileStore.swift; sourceTree = "<group>"; };
693E623A24A29B6B0017B222 /* SFSDKKeyValueEncryptedFileStoreTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SFSDKKeyValueEncryptedFileStoreTests.m; path = SalesforceSDKCoreTests/SFSDKKeyValueEncryptedFileStoreTests.m; sourceTree = SOURCE_ROOT; };
6941BE652D2F0E1B00CEC59B /* NewLoginHostView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = NewLoginHostView.swift; path = Login/LoginHost/NewLoginHostView.swift; sourceTree = "<group>"; };
694490C725B8E567007747CD /* SFSDKWindowManager+Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SFSDKWindowManager+Internal.h"; sourceTree = "<group>"; };
695E86A729EE24D0002BDEA6 /* SPConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPConfig.swift; sourceTree = "<group>"; };
695E86B729EF8D6E002BDEA6 /* SFSDKIDPAuthCodeLoginRequestCommand.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SFSDKIDPAuthCodeLoginRequestCommand.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -905,8 +905,6 @@
E1C80CE51C5AEE31001B3A21 /* SFSDKLoginHostListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SFSDKLoginHostListViewController.m; path = Login/LoginHost/SFSDKLoginHostListViewController.m; sourceTree = "<group>"; };
E1C80CE61C5AEE31001B3A21 /* SFSDKLoginHostStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SFSDKLoginHostStorage.h; path = Login/LoginHost/SFSDKLoginHostStorage.h; sourceTree = "<group>"; };
E1C80CE71C5AEE31001B3A21 /* SFSDKLoginHostStorage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SFSDKLoginHostStorage.m; path = Login/LoginHost/SFSDKLoginHostStorage.m; sourceTree = "<group>"; };
E1C80CE81C5AEE31001B3A21 /* SFSDKNewLoginHostViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SFSDKNewLoginHostViewController.h; path = Login/LoginHost/SFSDKNewLoginHostViewController.h; sourceTree = "<group>"; };
E1C80CE91C5AEE31001B3A21 /* SFSDKNewLoginHostViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SFSDKNewLoginHostViewController.m; path = Login/LoginHost/SFSDKNewLoginHostViewController.m; sourceTree = "<group>"; };
E1C80CEA1C5AEE31001B3A21 /* SFSDKTextFieldTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SFSDKTextFieldTableViewCell.h; path = Login/LoginHost/SFSDKTextFieldTableViewCell.h; sourceTree = "<group>"; };
E1C80CEB1C5AEE31001B3A21 /* SFSDKTextFieldTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SFSDKTextFieldTableViewCell.m; path = Login/LoginHost/SFSDKTextFieldTableViewCell.m; sourceTree = "<group>"; };
E1C80D071C5AF029001B3A21 /* SalesforceSDKAssets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = SalesforceSDKAssets.xcassets; path = ../../shared/resources/SalesforceSDKAssets.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1648,15 +1646,14 @@
E13950A21C53620B00575C03 /* LoginHost */ = {
isa = PBXGroup;
children = (
6941BE652D2F0E1B00CEC59B /* NewLoginHostView.swift */,
E1C80CE11C5AEE31001B3A21 /* SFSDKLoginHost.h */,
E1C80CE21C5AEE31001B3A21 /* SFSDKLoginHost.m */,
E1C80CE31C5AEE31001B3A21 /* SFSDKLoginHostDelegate.h */,
E1C80CE41C5AEE31001B3A21 /* SFSDKLoginHostListViewController.h */,
E1C80CE51C5AEE31001B3A21 /* SFSDKLoginHostListViewController.m */,
E1C80CE61C5AEE31001B3A21 /* SFSDKLoginHostStorage.h */,
E1C80CE71C5AEE31001B3A21 /* SFSDKLoginHostStorage.m */,
E1C80CE81C5AEE31001B3A21 /* SFSDKNewLoginHostViewController.h */,
E1C80CE91C5AEE31001B3A21 /* SFSDKNewLoginHostViewController.m */,
E1C80CEA1C5AEE31001B3A21 /* SFSDKTextFieldTableViewCell.h */,
E1C80CEB1C5AEE31001B3A21 /* SFSDKTextFieldTableViewCell.m */,
);
Expand Down Expand Up @@ -1698,7 +1695,6 @@
CE4CE3991C0E5272009F6029 /* SFSDKAsyncProcessListener.h in Headers */,
CE4CE3251C0E523B009F6029 /* UIScreen+SFAdditions.h in Headers */,
CE4CE38E1C0E526A009F6029 /* SFUserAccount.h in Headers */,
E1C80CF31C5AEE31001B3A21 /* SFSDKNewLoginHostViewController.h in Headers */,
B7FB26C71F78094A00FB25A2 /* SFSDKUserSelectionTableViewController.h in Headers */,
B72171562353BFF20022510F /* SFSDKAuthRequest.h in Headers */,
CE4CE33E1C0E524B009F6029 /* SFInstrumentation.h in Headers */,
Expand Down Expand Up @@ -2269,7 +2265,6 @@
B7A6ED32236A3F8600DBA451 /* UserAccountManager.swift in Sources */,
CE4CE3241C0E523B009F6029 /* UIDevice+SFHardware.m in Sources */,
CE675A381E0B2CC6002DBF5A /* SFSDKSoslReturningBuilder.m in Sources */,
E1C80CF41C5AEE31001B3A21 /* SFSDKNewLoginHostViewController.m in Sources */,
CE4CE3281C0E523B009F6029 /* NSData+SFSDKUtils.m in Sources */,
CED452BD1D808D0C009266EB /* SFRestAPI+QueryBuilder.m in Sources */,
B71129111F8A780800436CFB /* SFSDKAlertMessageBuilder.m in Sources */,
Expand All @@ -2295,6 +2290,7 @@
B7460C1C2347E1A100C7512E /* SFSDKBatchResponse.m in Sources */,
A3C7476129F709EB00D72B7F /* BiometricAuthenticationManagerInternal.swift in Sources */,
B7FB26DB1F78096300FB25A2 /* SFSDKIDPErrorHandler.m in Sources */,
6941BE662D2F0E1B00CEC59B /* NewLoginHostView.swift in Sources */,
B7677051223AE5E400545C90 /* SFUserAccountManager+Instrumentation.m in Sources */,
E1C80CF01C5AEE31001B3A21 /* SFSDKLoginHostListViewController.m in Sources */,
B773CCF81F8200BD00D2D1B2 /* SFSDKIDPLoginRequestCommand.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
//
// NewLoginHostView.swift
// SalesforceSDKCore
//
// Created by Brianna Birman on 12/19/24.
// Copyright (c) 2024-present, salesforce.com, inc. All rights reserved.
//
// Redistribution and use of this software in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice, this list of conditions
// and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice, this list of
// conditions and the following disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of salesforce.com, inc. nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission of salesforce.com, inc.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
// WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import SwiftUI


@objc(SFSDKNewLoginHostViewController)
class NewLoginHostViewController: NSObject {
@objc public static func viewController(saveAction: @escaping ((String, String?) -> Void)) -> UIViewController {
let view = NewLoginHostView(saveAction: saveAction)
return UIHostingController(rootView: view)
}
}

struct NewLoginHostField: View {
let fieldLabel: String
let fieldPlaceholder: String
@Binding var fieldValue: String

var body: some View {
VStack(alignment: .leading, spacing: 5) {
Text(fieldLabel)
TextField(fieldPlaceholder, text: $fieldValue)
.autocorrectionDisabled()
.padding()
.background(
RoundedRectangle(cornerSize: CGSize(width: 10, height: 10))
.stroke(Color(uiColor: .label), lineWidth: 0.5)
)
}
}
}

struct NewLoginHostView: View {
@State var host = ""
@State var label = ""
private var saveAction: ((String, String?) -> Void)

init(saveAction: @escaping ((String, String?) -> Void)) {
self.saveAction = saveAction
}

func save() {
var hostToSave = host.trimmingCharacters(in: .whitespaces)
if let httpsRange = hostToSave.range(of: "://") {
hostToSave = String(host[...httpsRange.upperBound])
}
saveAction(hostToSave, label.trimmingCharacters(in: .whitespaces))
}

var body: some View {
List {
NewLoginHostField(fieldLabel: SFSDKResourceUtils.localizedString("LOGIN_SERVER_URL"),
fieldPlaceholder: SFSDKResourceUtils.localizedString("LOGIN_SERVER_URL_PLACEHOLDER"),
fieldValue: $host)
.keyboardType(.URL)
.autocapitalization(.none)
.listRowSeparator(.hidden)

NewLoginHostField(fieldLabel: SFSDKResourceUtils.localizedString("LOGIN_SERVER_NAME"),
fieldPlaceholder: SFSDKResourceUtils.localizedString("LOGIN_SERVER_NAME_PLACEHOLDER"),
fieldValue: $label)
.listRowSeparator(.hidden)
.padding(.bottom)
}

.background(Color(uiColor: .secondarySystemBackground))
.scrollDisabled(true)
.listStyle(.plain)
.navigationTitle(SFSDKResourceUtils.localizedString("LOGIN_ADD_SERVER"))
.toolbar {
ToolbarItemGroup(placement: .topBarTrailing) {
Button {
save()
} label: {
Text(SFSDKResourceUtils.localizedString("DONE_BUTTON")).bold()
}
.disabled(host.trimmingCharacters(in: .whitespaces).isEmpty)
}
}.tint(.white)
}
}

#Preview {
NewLoginHostView {_,_ in }
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
*/

#import "SFSDKLoginHostListViewController.h"
#import "SFSDKNewLoginHostViewController.h"
#import "SFSDKLoginHostStorage.h"
#import "SFSDKLoginHost.h"
#import "SFSDKResourceUtils.h"
#import "SFManagedPreferences.h"
#import "SFUserAccountManager.h"
#import "SFSDKViewUtils.h"
#import <SalesforceSDKCore/SalesforceSDKCore-Swift.h>

static NSString * const SFDCLoginHostListCellIdentifier = @"SFDCLoginHostListCellIdentifier";

@interface SFSDKLoginHostListViewController () <UINavigationControllerDelegate>
Expand Down Expand Up @@ -98,9 +99,10 @@ - (void)showAddLoginHost {
* Invoked when the user presses the Add button. This method presents the new login host view.
*/
- (void)showAddLoginHost:(id)sender {
SFSDKNewLoginHostViewController *detailViewController = [[SFSDKNewLoginHostViewController alloc] initWithStyle:UITableViewStyleGrouped];
detailViewController.loginHostListViewController = self;

UIViewController *detailViewController = [SFSDKNewLoginHostViewController viewControllerWithSaveAction:^(NSString * _Nonnull host, NSString * _Nullable label) {
[self addLoginHost:[SFSDKLoginHost hostWithName:label host:host deletable:YES]];
}];

if ([self.delegate respondsToSelector:@selector(hostListViewController:willPresentLoginHostViewController:)]) {
[self.delegate hostListViewController:self willPresentLoginHostViewController:self];
}
Expand Down

This file was deleted.

Loading

0 comments on commit 7889621

Please sign in to comment.