Merge branch 'feature/tile_container_colors' into 'develop'
Digital PCT265 story ONEAPP-7592 - Updates to tile container to allow custom colors. ### Summary Updating tile container to allow any color ### JIRA Ticket https://onejira.verizon.com/browse/ONEAPP-7592 Co-authored-by: Scott Pfeil <Scott.Pfeil3@verizonwireless.com> See merge request https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui/-/merge_requests/1108
This commit is contained in:
commit
7a948b3556
@ -74,7 +74,7 @@ extension BaseItemPickerEntryField {
|
|||||||
|
|
||||||
@objc open override func setAccessibilityString(_ accessibilityString: String?) {
|
@objc open override func setAccessibilityString(_ accessibilityString: String?) {
|
||||||
|
|
||||||
var accessibilityString = accessibilityString ?? ""
|
let accessibilityString = accessibilityString ?? ""
|
||||||
textField.accessibilityTraits = .staticText
|
textField.accessibilityTraits = .staticText
|
||||||
textField.accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "textfield_picker_item")
|
textField.accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "textfield_picker_item")
|
||||||
textField.accessibilityLabel = "\(accessibilityString) \(textField.isEnabled ? "" : MVMCoreUIUtility.hardcodedString(withKey: "textfield_disabled_state") ?? "")"
|
textField.accessibilityLabel = "\(accessibilityString) \(textField.isEnabled ? "" : MVMCoreUIUtility.hardcodedString(withKey: "textfield_disabled_state") ?? "")"
|
||||||
|
|||||||
@ -397,7 +397,7 @@ extension TextEntryField {
|
|||||||
|
|
||||||
@objc open override func setAccessibilityString(_ accessibilityString: String?) {
|
@objc open override func setAccessibilityString(_ accessibilityString: String?) {
|
||||||
|
|
||||||
var accessibilityString = accessibilityString ?? ""
|
let accessibilityString = accessibilityString ?? ""
|
||||||
|
|
||||||
textField.accessibilityLabel = "\(accessibilityString) \(textField.isEnabled ? "" : MVMCoreUIUtility.hardcodedString(withKey: "textfield_disabled_state") ?? "")"
|
textField.accessibilityLabel = "\(accessibilityString) \(textField.isEnabled ? "" : MVMCoreUIUtility.hardcodedString(withKey: "textfield_disabled_state") ?? "")"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import VDS
|
import VDS
|
||||||
|
import MVMCore
|
||||||
|
|
||||||
open class TileContainerModel: TileContainerBaseModel<TileContainer.Padding, TileContainer>, ParentMoleculeModelProtocol, MoleculeModelProtocol {
|
open class TileContainerModel: TileContainerBaseModel<TileContainer.Padding, TileContainer>, ParentMoleculeModelProtocol, MoleculeModelProtocol {
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ open class TileContainerModel: TileContainerBaseModel<TileContainer.Padding, Til
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString
|
||||||
molecule = try container.decodeModelIfPresent(codingKey: .molecule)
|
molecule = try container.decodeMoleculeIfPresent(codingKey: .molecule)
|
||||||
try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -95,7 +95,11 @@ extension VDS.TileContainerBase.BackgroundColor: Codable {
|
|||||||
case "black":
|
case "black":
|
||||||
self = .black
|
self = .black
|
||||||
default:
|
default:
|
||||||
self = .custom(type)
|
if let color = try? Color(from: decoder) {
|
||||||
|
self = .custom(color.hex)
|
||||||
|
} else {
|
||||||
|
self = .custom(type)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,7 +91,7 @@ public struct DeprecatedHeadlineBodyHelper {
|
|||||||
|
|
||||||
public func createTitleLockupModel(defaultStyle: HeadlineBodyModel.Style = .header, headlineBody: HeadlineBodyModel) throws -> TitleLockupModel {
|
public func createTitleLockupModel(defaultStyle: HeadlineBodyModel.Style = .header, headlineBody: HeadlineBodyModel) throws -> TitleLockupModel {
|
||||||
guard let headline = headlineBody.headline else { throw ModelRegistry.Error.decoderOther(message: "headline is required for this use case.") }
|
guard let headline = headlineBody.headline else { throw ModelRegistry.Error.decoderOther(message: "headline is required for this use case.") }
|
||||||
var body = headlineBody.body
|
let body = headlineBody.body
|
||||||
switch headlineBody.style ?? defaultStyle {
|
switch headlineBody.style ?? defaultStyle {
|
||||||
case .landingHeader:
|
case .landingHeader:
|
||||||
headline.fontStyle = Styler.Font.RegularTitle2XLarge
|
headline.fontStyle = Styler.Font.RegularTitle2XLarge
|
||||||
@ -103,13 +103,13 @@ public struct DeprecatedHeadlineBodyHelper {
|
|||||||
headline.fontStyle = Styler.Font.RegularTitleXLarge
|
headline.fontStyle = Styler.Font.RegularTitleXLarge
|
||||||
body?.fontStyle = Styler.Font.RegularTitleMedium
|
body?.fontStyle = Styler.Font.RegularTitleMedium
|
||||||
}
|
}
|
||||||
let model = try TitleLockupModel(title: headline, subTitle: body)
|
let model = TitleLockupModel(title: headline, subTitle: body)
|
||||||
model.id = headlineBody.id
|
model.id = headlineBody.id
|
||||||
return model
|
return model
|
||||||
}
|
}
|
||||||
|
|
||||||
public func createHeadlineBodyModel(titleLockup: TitleLockupModel) -> HeadlineBodyModel {
|
public func createHeadlineBodyModel(titleLockup: TitleLockupModel) -> HeadlineBodyModel {
|
||||||
var headlineBody = HeadlineBodyModel(headline: titleLockup.title)
|
let headlineBody = HeadlineBodyModel(headline: titleLockup.title)
|
||||||
headlineBody.body = titleLockup.subTitle
|
headlineBody.body = titleLockup.subTitle
|
||||||
headlineBody.id = titleLockup.id
|
headlineBody.id = titleLockup.id
|
||||||
return headlineBody
|
return headlineBody
|
||||||
|
|||||||
@ -94,7 +94,7 @@ open class HeadlineBodyModel: ParentMoleculeModelProtocol {
|
|||||||
public extension HeadlineBodyModel {
|
public extension HeadlineBodyModel {
|
||||||
func createHeaderTitleLockupModel(defaultStyle: Style = .header) throws -> TitleLockupModel {
|
func createHeaderTitleLockupModel(defaultStyle: Style = .header) throws -> TitleLockupModel {
|
||||||
guard let headline = headline else { throw ModelRegistry.Error.decoderOther(message: "headline is required for this use case.") }
|
guard let headline = headline else { throw ModelRegistry.Error.decoderOther(message: "headline is required for this use case.") }
|
||||||
var body = self.body
|
let body = self.body
|
||||||
switch style ?? defaultStyle {
|
switch style ?? defaultStyle {
|
||||||
case .landingHeader:
|
case .landingHeader:
|
||||||
headline.fontStyle = Styler.Font.RegularTitle2XLarge
|
headline.fontStyle = Styler.Font.RegularTitle2XLarge
|
||||||
@ -106,7 +106,7 @@ public extension HeadlineBodyModel {
|
|||||||
headline.fontStyle = Styler.Font.RegularTitleXLarge
|
headline.fontStyle = Styler.Font.RegularTitleXLarge
|
||||||
body?.fontStyle = Styler.Font.RegularTitleMedium
|
body?.fontStyle = Styler.Font.RegularTitleMedium
|
||||||
}
|
}
|
||||||
let model = try TitleLockupModel(title: headline, subTitle: body)
|
let model = TitleLockupModel(title: headline, subTitle: body)
|
||||||
model.id = id
|
model.id = id
|
||||||
return model
|
return model
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,16 +35,16 @@ public class PageGetContactBehavior: PageVisibilityBehavior {
|
|||||||
CNContactStore().requestAccess(for: .contacts) { [weak self] (access, error) in
|
CNContactStore().requestAccess(for: .contacts) { [weak self] (access, error) in
|
||||||
guard access,
|
guard access,
|
||||||
error == nil,
|
error == nil,
|
||||||
let rootMolecules = self?.delegate?.moleculeDelegate?.getRootMolecules() else { return }
|
let rootMolecules = delegateObject?.moleculeDelegate?.getRootMolecules() else { return }
|
||||||
// Iterate models and provide contact
|
// Iterate models and provide contact
|
||||||
self?.getContacts(for: rootMolecules)
|
self?.getContacts(for: rootMolecules)
|
||||||
|
|
||||||
// Tell template to update
|
// Tell template to update
|
||||||
MVMCoreDispatchUtility.performBlock(onMainThread: {
|
Task { @MainActor in
|
||||||
// TODO: move to protocol function instead
|
// TODO: move to protocol function instead
|
||||||
guard let controller = self?.delegate?.moleculeDelegate as? ViewController else { return }
|
guard let controller = delegateObject?.moleculeDelegate as? ViewController else { return }
|
||||||
controller.handleNewData()
|
controller.handleNewData()
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -230,6 +230,12 @@ extension UIColor {
|
|||||||
return UIColor(named: name, in: MVMCoreUIUtility.bundleForMVMCoreUI(), compatibleWith: nil)!
|
return UIColor(named: name, in: MVMCoreUIUtility.bundleForMVMCoreUI(), compatibleWith: nil)!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a color corresponding to the passed in color name.
|
||||||
|
@objc
|
||||||
|
public static func mvmCoreUIColor(with name: String) -> UIColor? {
|
||||||
|
return UIColor.names[name]?.uiColor
|
||||||
|
}
|
||||||
|
|
||||||
/// Convenience to get a grayscale UIColor where the same value is used for red, green, and blue.
|
/// Convenience to get a grayscale UIColor where the same value is used for red, green, and blue.
|
||||||
public class func grayscale(rgb: Int, alpha: CGFloat = 1.0) -> UIColor {
|
public class func grayscale(rgb: Int, alpha: CGFloat = 1.0) -> UIColor {
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "UIColor+MFConvenience.h"
|
#import "UIColor+MFConvenience.h"
|
||||||
|
#import <MVMCoreUI/MVMCoreUI-Swift.h>
|
||||||
@import MVMCore.MVMCoreDispatchUtility;
|
@import MVMCore.MVMCoreDispatchUtility;
|
||||||
|
|
||||||
@implementation UIColor (MFConvenience)
|
@implementation UIColor (MFConvenience)
|
||||||
@ -298,6 +299,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
+ (nullable UIColor *)mfGetColorForString:(nullable NSString *)string {
|
+ (nullable UIColor *)mfGetColorForString:(nullable NSString *)string {
|
||||||
|
if ([string hasPrefix:@"#"]) {
|
||||||
|
return [self mfGetColorForHex:string];
|
||||||
|
}
|
||||||
|
|
||||||
static NSDictionary *stringColorMapping;
|
static NSDictionary *stringColorMapping;
|
||||||
static dispatch_once_t once;
|
static dispatch_once_t once;
|
||||||
dispatch_once(&once, ^{
|
dispatch_once(&once, ^{
|
||||||
@ -327,14 +332,9 @@
|
|||||||
|
|
||||||
UIColor *color = nil;
|
UIColor *color = nil;
|
||||||
if (string && string.length > 0) {
|
if (string && string.length > 0) {
|
||||||
color = [stringColorMapping objectForKey:string];
|
color = [stringColorMapping objectForKey:string] ?: [UIColor mvmCoreUIColorWith:string];
|
||||||
if (!color){
|
|
||||||
color = [UIColor blackColor];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
color = [UIColor blackColor];
|
|
||||||
}
|
}
|
||||||
return color;
|
return color ?: [UIColor blackColor];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (nonnull UIColor *)mfGetColorForHex:(nonnull NSString *) hexString {
|
+ (nonnull UIColor *)mfGetColorForHex:(nonnull NSString *) hexString {
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import MVMCore
|
||||||
|
|
||||||
extension UIStackView: MVMCoreViewProtocol {
|
extension UIStackView: MVMCoreViewProtocol {
|
||||||
public func updateView(_ size: CGFloat) {
|
public func updateView(_ size: CGFloat) {
|
||||||
@ -16,7 +17,7 @@ extension UIStackView: MVMCoreViewProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A convenience function for updating molecules. If model is nil, view is hidden.
|
/// A convenience function for updating molecules. If model is nil, view is hidden.
|
||||||
open func updateContainedMolecules(with models: [MoleculeModelProtocol?], _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
public func updateContainedMolecules(with models: [MoleculeModelProtocol?], _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
for (index, item) in arrangedSubviews.enumerated() {
|
for (index, item) in arrangedSubviews.enumerated() {
|
||||||
if let model = models[index] {
|
if let model = models[index] {
|
||||||
(item as? MoleculeViewProtocol)?.set(with: model, delegateObject, additionalData)
|
(item as? MoleculeViewProtocol)?.set(with: model, delegateObject, additionalData)
|
||||||
|
|||||||
@ -404,7 +404,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol,
|
|||||||
|
|
||||||
public func update(percentage: CGFloat) {
|
public func update(percentage: CGFloat) {
|
||||||
guard customInteractor?.interactive == true,
|
guard customInteractor?.interactive == true,
|
||||||
let index = index else { return }
|
let _ = index else { return }
|
||||||
// tabs.progress(from: tabs.selectedIndex, toIndex: index, percentage: percentage)
|
// tabs.progress(from: tabs.selectedIndex, toIndex: index, percentage: percentage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user