Skip to content

Commit

Permalink
Merge pull request #3795 from bbirman/add-connection
Browse files Browse the repository at this point in the history
Update tint to use config and centralize the default tint color
  • Loading branch information
bbirman authored Jan 9, 2025
2 parents 7889621 + 7068109 commit 900bd6a
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ - (void)showSettingsIcon {
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(showLoginHost:)];
rightButton.accessibilityLabel = [SFSDKResourceUtils localizedString:@"LOGIN_CHOOSE_SERVER"];
self.navBar.topItem.rightBarButtonItem = rightButton;
self.navBar.topItem.rightBarButtonItem.tintColor = [UIColor whiteColor];
self.navBar.topItem.rightBarButtonItem.tintColor = [UIColor salesforceNavBarTintColor];
}

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

@objc(SFSDKNewLoginHostViewController)
class NewLoginHostViewController: NSObject {
@objc public static func viewController(saveAction: @escaping ((String, String?) -> Void)) -> UIViewController {
let view = NewLoginHostView(saveAction: saveAction)
@objc public static func viewController(config: SFSDKViewControllerConfig?, saveAction: @escaping ((String, String?) -> Void)) -> UIViewController {
let view = NewLoginHostView(viewControllerConfig: config, saveAction: saveAction)
return UIHostingController(rootView: view)
}
}
Expand Down Expand Up @@ -59,9 +59,15 @@ struct NewLoginHostView: View {
@State var host = ""
@State var label = ""
private var saveAction: ((String, String?) -> Void)
private var navBarTintColor: Color

init(saveAction: @escaping ((String, String?) -> Void)) {
init(viewControllerConfig: SFSDKViewControllerConfig?, saveAction: @escaping ((String, String?) -> Void)) {
self.saveAction = saveAction
if let navBarTintColor = viewControllerConfig?.navigationBarTintColor {
self.navBarTintColor = Color(uiColor: navBarTintColor)
} else {
self.navBarTintColor = Color(uiColor: UIColor.salesforceNavBarTint)
}
}

func save() {
Expand Down Expand Up @@ -99,12 +105,13 @@ struct NewLoginHostView: View {
} label: {
Text(SFSDKResourceUtils.localizedString("DONE_BUTTON")).bold()
}
.tint(navBarTintColor)
.disabled(host.trimmingCharacters(in: .whitespaces).isEmpty)
}
}.tint(.white)
}
}
}

#Preview {
NewLoginHostView {_,_ in }
NewLoginHostView(viewControllerConfig: nil) {_,_ in }
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#import <UIKit/UIKit.h>
#import <SalesforceSDKCore/SFSDKLoginHostDelegate.h>
#import <SalesforceSDKCore/SFSDKViewControllerConfig.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -57,6 +58,8 @@ NS_SWIFT_NAME(LoginHostListViewController)
*/
@property (nonatomic,assign) BOOL hidesAddButton;

@property (nonatomic) SFSDKViewControllerConfig *config;

/**
* Adds a new login host. Also updates the underlying storage and refreshes
* the list of login hosts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ - (void)showAddLoginHost {
* Invoked when the user presses the Add button. This method presents the new login host view.
*/
- (void)showAddLoginHost:(id)sender {
UIViewController *detailViewController = [SFSDKNewLoginHostViewController viewControllerWithSaveAction:^(NSString * _Nonnull host, NSString * _Nullable label) {
UIViewController *detailViewController = [SFSDKNewLoginHostViewController viewControllerWithConfig:self.config saveAction:^(NSString * _Nonnull host, NSString * _Nullable label) {
[self addLoginHost:[SFSDKLoginHost hostWithName:label host:host deletable:YES]];
}];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ - (UIView *)createTitleItem {

- (SFSDKLoginHostListViewController *)createLoginHostListViewController {
SFSDKLoginHostListViewController *loginHostListViewController = [[SFSDKLoginHostListViewController alloc] initWithStyle:UITableViewStylePlain];
loginHostListViewController.config = self.config;
return loginHostListViewController;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ - (instancetype)init {
if (self) {
self.navBarColor = [UIColor salesforceBlueColor];
self.navBarTitleColor = [UIColor whiteColor];
self.navBarTintColor = [UIColor whiteColor];
self.navBarTintColor = [UIColor salesforceNavBarTintColor];
self.navBarFont = nil;
_showNavbar = YES;
_showSettingsIcon = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
#import "SFSDKViewUtils.h"
#import "SFSDKViewControllerConfig.h"
#import "UIColor+SFColors.h"

@implementation SFSDKViewUtils

Expand All @@ -50,7 +51,7 @@ + (void)styleNavigationBar:(UINavigationBar *)navigationBar config:(SFSDKViewCon
[textAttributes setObject:config.navBarTintColor forKey:NSForegroundColorAttributeName];
} else {
// default color
navigationBar.tintColor = [UIColor whiteColor];
navigationBar.tintColor = [UIColor salesforceNavBarTintColor];
}

if (config.navBarTitleColor){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (class, nonatomic, readonly) UIColor *salesforceAltBackgroundColor;
@property (class, nonatomic, readonly) UIColor *salesforceAlt2BackgroundColor;
@property (class, nonatomic, readonly) UIColor *salesforceTableCellBackgroundColor;
@property (class, nonatomic, readonly) UIColor *salesforceNavBarTintColor;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ + (UIColor *)salesforceTableCellBackgroundColor{
return [UIColor colorWithRed: 245.0/255.0 green:246.0/255.0 blue: 250.0/255.0 alpha: 1.0];
}

+ (UIColor *)salesforceNavBarTintColor {
return [UIColor whiteColor];
}

+ (UIColor *)sfsdk_colorForLightStyle:(UIColor *)lightStyleColor darkStyle:(UIColor *)darkStyleColor {
return [[UIColor alloc] initWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) {
if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ - (UINavigationBar*) createNavBar
[navBar setItems:@[navItem] animated:YES];
navBar.translucent = NO;
navBar.barTintColor = [UIColor salesforceBlueColor];
navBar.tintColor = [UIColor whiteColor];
navBar.tintColor = [UIColor salesforceNavBarTintColor];
navBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:kNavBarTitleFontSize]};
[self.view addSubview:navBar];
return navBar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ - (UINavigationBar*) createNavBar
[navBar setItems:@[navItem] animated:YES];
navBar.translucent = NO;
navBar.barTintColor = [UIColor salesforceBlueColor];
navBar.tintColor = [UIColor whiteColor];
navBar.tintColor = [UIColor salesforceNavBarTintColor];
navBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:kNavBarTitleFontSize]};
[self.view addSubview:navBar];
return navBar;
Expand Down

0 comments on commit 900bd6a

Please sign in to comment.