remove extra view I created
This commit is contained in:
parent
3f6fcdbe16
commit
90d2290843
@ -147,7 +147,6 @@
|
|||||||
D29DF32521ED0DA2003B2FB9 /* TextButtonView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF32321ED0DA2003B2FB9 /* TextButtonView.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
D29DF32521ED0DA2003B2FB9 /* TextButtonView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF32321ED0DA2003B2FB9 /* TextButtonView.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
D29DF32C21EE8736003B2FB9 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D29DF32821EE8736003B2FB9 /* Localizable.strings */; };
|
D29DF32C21EE8736003B2FB9 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D29DF32821EE8736003B2FB9 /* Localizable.strings */; };
|
||||||
D29DF32E21EE8C3D003B2FB9 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D29DF32D21EE8C3D003B2FB9 /* Media.xcassets */; };
|
D29DF32E21EE8C3D003B2FB9 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D29DF32D21EE8C3D003B2FB9 /* Media.xcassets */; };
|
||||||
D2A421BF226A14F100A05A88 /* ConstrainingMoleculeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A421BE226A14F100A05A88 /* ConstrainingMoleculeView.swift */; };
|
|
||||||
D2A514582211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
D2A514582211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */; };
|
D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */; };
|
||||||
D2A5145D2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
D2A5145D2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
@ -312,7 +311,6 @@
|
|||||||
D29DF32A21EE8736003B2FB9 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
|
D29DF32A21EE8736003B2FB9 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
D29DF32B21EE8736003B2FB9 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
D29DF32B21EE8736003B2FB9 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
||||||
D29DF32D21EE8C3D003B2FB9 /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = "<group>"; };
|
D29DF32D21EE8C3D003B2FB9 /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = "<group>"; };
|
||||||
D2A421BE226A14F100A05A88 /* ConstrainingMoleculeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstrainingMoleculeView.swift; sourceTree = "<group>"; };
|
|
||||||
D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIMoleculeMappingObject.h; sourceTree = "<group>"; };
|
D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIMoleculeMappingObject.h; sourceTree = "<group>"; };
|
||||||
D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIMoleculeMappingObject.m; sourceTree = "<group>"; };
|
D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIMoleculeMappingObject.m; sourceTree = "<group>"; };
|
||||||
D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIMoleculeViewProtocol.h; sourceTree = "<group>"; };
|
D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIMoleculeViewProtocol.h; sourceTree = "<group>"; };
|
||||||
@ -579,7 +577,6 @@
|
|||||||
D29DF28621E7AC2B003B2FB9 /* MFLabel.m */,
|
D29DF28621E7AC2B003B2FB9 /* MFLabel.m */,
|
||||||
D29DF31E21ED0CBA003B2FB9 /* LabelView.h */,
|
D29DF31E21ED0CBA003B2FB9 /* LabelView.h */,
|
||||||
D29DF31F21ED0CBA003B2FB9 /* LabelView.m */,
|
D29DF31F21ED0CBA003B2FB9 /* LabelView.m */,
|
||||||
D2A421BE226A14F100A05A88 /* ConstrainingMoleculeView.swift */,
|
|
||||||
D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */,
|
D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */,
|
||||||
D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */,
|
D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */,
|
||||||
D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */,
|
D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */,
|
||||||
@ -880,7 +877,6 @@
|
|||||||
D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */,
|
D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */,
|
||||||
DBC4391922442197001AB423 /* DashLine.swift in Sources */,
|
DBC4391922442197001AB423 /* DashLine.swift in Sources */,
|
||||||
D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */,
|
D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */,
|
||||||
D2A421BF226A14F100A05A88 /* ConstrainingMoleculeView.swift in Sources */,
|
|
||||||
D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */,
|
D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */,
|
||||||
D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */,
|
D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */,
|
||||||
D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */,
|
D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */,
|
||||||
|
|||||||
@ -1,55 +0,0 @@
|
|||||||
//
|
|
||||||
// ConstrainingMoleculeView.swift
|
|
||||||
// MVMCoreUI
|
|
||||||
//
|
|
||||||
// Created by Scott Pfeil on 4/19/19.
|
|
||||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
@objcMembers open class ConstrainingMoleculeView: MFView {
|
|
||||||
var molecule: (UIView & MVMCoreUIMoleculeViewProtocol)?
|
|
||||||
|
|
||||||
public init(withMolecule molecule: UIView & MVMCoreUIMoleculeViewProtocol) {
|
|
||||||
self.molecule = molecule
|
|
||||||
super.init(frame: .zero)
|
|
||||||
}
|
|
||||||
|
|
||||||
required public init?(coder aDecoder: NSCoder) {
|
|
||||||
super.init(coder: aDecoder)
|
|
||||||
}
|
|
||||||
|
|
||||||
open override func setupView() {
|
|
||||||
super.setupView()
|
|
||||||
if let molecule = molecule, molecule.superview == nil {
|
|
||||||
addSubview(molecule)
|
|
||||||
molecule.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
|
||||||
molecule.leftAnchor.constraint(equalTo: layoutMarginsGuide.leftAnchor).isActive = true
|
|
||||||
layoutMarginsGuide.rightAnchor.constraint(equalTo: molecule.rightAnchor).isActive = true
|
|
||||||
bottomAnchor.constraint(equalTo: molecule.bottomAnchor).isActive = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
open override func updateView(_ size: CGFloat) {
|
|
||||||
if let molecule = molecule as? MVMCoreViewProtocol {
|
|
||||||
molecule.updateView(size)
|
|
||||||
}
|
|
||||||
MFStyler.setDefaultMarginsFor(self, size: size)
|
|
||||||
}
|
|
||||||
|
|
||||||
open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) {
|
|
||||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
|
||||||
guard let json = json, let molecule = molecule else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
molecule.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
|
||||||
if let backgroundColor = molecule.backgroundColor {
|
|
||||||
self.backgroundColor = backgroundColor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
open override func setAsMolecule() {
|
|
||||||
molecule?.setAsMolecule?()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -26,6 +26,9 @@
|
|||||||
// Returns a view with the provided view as a subview, pinned.
|
// Returns a view with the provided view as a subview, pinned.
|
||||||
+ (nonnull ViewConstrainingView *)viewConstrainingView:(nonnull UIView *)view;
|
+ (nonnull ViewConstrainingView *)viewConstrainingView:(nonnull UIView *)view;
|
||||||
|
|
||||||
|
// Can be initialized with a molecule to constrain
|
||||||
|
- (nullable instancetype)initWithMolecule:(nonnull UIView <MVMCoreUIMoleculeViewProtocol>*)molecule;
|
||||||
|
|
||||||
// Use these to sets the constants, because subclasses may align differently.
|
// Use these to sets the constants, because subclasses may align differently.
|
||||||
- (void)setPinConstantsWithInsets:(UIEdgeInsets)insets;
|
- (void)setPinConstantsWithInsets:(UIEdgeInsets)insets;
|
||||||
- (void)setTopPinConstant:(CGFloat)top left:(CGFloat)left bottom:(CGFloat)bottom right:(CGFloat)right;
|
- (void)setTopPinConstant:(CGFloat)top left:(CGFloat)left bottom:(CGFloat)bottom right:(CGFloat)right;
|
||||||
@ -41,6 +44,9 @@
|
|||||||
// Pins all edges to its super. 0 constant
|
// Pins all edges to its super. 0 constant
|
||||||
- (void)pinToSuperView;
|
- (void)pinToSuperView;
|
||||||
|
|
||||||
|
// Add a view to be constrained in this view.
|
||||||
|
- (void)addConstrainedView:(nonnull UIView *)view;
|
||||||
|
|
||||||
// Resets all the constraints to default.
|
// Resets all the constraints to default.
|
||||||
- (void)resetConstraints;
|
- (void)resetConstraints;
|
||||||
|
|
||||||
|
|||||||
@ -13,10 +13,18 @@
|
|||||||
|
|
||||||
@interface ViewConstrainingView ()
|
@interface ViewConstrainingView ()
|
||||||
@property (weak, nullable, nonatomic) UIView *constrainedView;
|
@property (weak, nullable, nonatomic) UIView *constrainedView;
|
||||||
|
@property (strong, nullable, nonatomic) UIView <MVMCoreUIMoleculeViewProtocol>*molecule;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation ViewConstrainingView
|
@implementation ViewConstrainingView
|
||||||
|
|
||||||
|
- (nullable instancetype)initWithMolecule:(nonnull UIView <MVMCoreUIMoleculeViewProtocol>*)molecule {
|
||||||
|
if (self = [super init]) {
|
||||||
|
self.molecule = molecule;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
+ (nonnull ViewConstrainingView *)emptyView {
|
+ (nonnull ViewConstrainingView *)emptyView {
|
||||||
ViewConstrainingView *view = [[ViewConstrainingView alloc] initWithFrame:CGRectZero];
|
ViewConstrainingView *view = [[ViewConstrainingView alloc] initWithFrame:CGRectZero];
|
||||||
view.translatesAutoresizingMaskIntoConstraints = NO;
|
view.translatesAutoresizingMaskIntoConstraints = NO;
|
||||||
@ -28,27 +36,7 @@
|
|||||||
ViewConstrainingView *constrainingView = [[ViewConstrainingView alloc] initWithFrame:CGRectZero];
|
ViewConstrainingView *constrainingView = [[ViewConstrainingView alloc] initWithFrame:CGRectZero];
|
||||||
constrainingView.translatesAutoresizingMaskIntoConstraints = NO;
|
constrainingView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||||
constrainingView.backgroundColor = [UIColor clearColor];
|
constrainingView.backgroundColor = [UIColor clearColor];
|
||||||
|
[constrainingView addConstrainedView:view];
|
||||||
view.translatesAutoresizingMaskIntoConstraints = NO;
|
|
||||||
[constrainingView addSubview:view];
|
|
||||||
constrainingView.constrainedView = view;
|
|
||||||
|
|
||||||
NSLayoutConstraint *leftPin = [view.leftAnchor constraintEqualToAnchor:constrainingView.leftAnchor];
|
|
||||||
constrainingView.leftPin = leftPin;
|
|
||||||
leftPin.active = YES;
|
|
||||||
|
|
||||||
NSLayoutConstraint *topPin = [view.topAnchor constraintEqualToAnchor:constrainingView.topAnchor];
|
|
||||||
constrainingView.topPin = topPin;
|
|
||||||
topPin.active = YES;
|
|
||||||
|
|
||||||
NSLayoutConstraint *bottomPin = [constrainingView.bottomAnchor constraintEqualToAnchor:view.bottomAnchor];
|
|
||||||
constrainingView.bottomPin = bottomPin;
|
|
||||||
bottomPin.active = YES;
|
|
||||||
|
|
||||||
NSLayoutConstraint *rightPin = [constrainingView.rightAnchor constraintEqualToAnchor:view.rightAnchor];
|
|
||||||
constrainingView.rightPin = rightPin;
|
|
||||||
rightPin.active = YES;
|
|
||||||
|
|
||||||
return constrainingView;
|
return constrainingView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,10 +103,35 @@
|
|||||||
self.backgroundColor = [UIColor clearColor];
|
self.backgroundColor = [UIColor clearColor];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)addConstrainedView:(nonnull UIView *)view {
|
||||||
|
view.translatesAutoresizingMaskIntoConstraints = NO;
|
||||||
|
[self addSubview:view];
|
||||||
|
self.constrainedView = view;
|
||||||
|
|
||||||
|
NSLayoutConstraint *leftPin = [view.leftAnchor constraintEqualToAnchor:self.leftAnchor];
|
||||||
|
self.leftPin = leftPin;
|
||||||
|
leftPin.active = YES;
|
||||||
|
|
||||||
|
NSLayoutConstraint *topPin = [view.topAnchor constraintEqualToAnchor:self.topAnchor];
|
||||||
|
self.topPin = topPin;
|
||||||
|
topPin.active = YES;
|
||||||
|
|
||||||
|
NSLayoutConstraint *bottomPin = [self.bottomAnchor constraintEqualToAnchor:view.bottomAnchor];
|
||||||
|
self.bottomPin = bottomPin;
|
||||||
|
bottomPin.active = YES;
|
||||||
|
|
||||||
|
NSLayoutConstraint *rightPin = [self.rightAnchor constraintEqualToAnchor:view.rightAnchor];
|
||||||
|
self.rightPin = rightPin;
|
||||||
|
rightPin.active = YES;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setupView {
|
- (void)setupView {
|
||||||
[super setupView];
|
[super setupView];
|
||||||
self.translatesAutoresizingMaskIntoConstraints = NO;
|
self.translatesAutoresizingMaskIntoConstraints = NO;
|
||||||
self.backgroundColor = [UIColor clearColor];
|
self.backgroundColor = [UIColor clearColor];
|
||||||
|
if (!self.molecule.superview) {
|
||||||
|
[self addConstrainedView:self.molecule];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateView:(CGFloat)size {
|
- (void)updateView:(CGFloat)size {
|
||||||
@ -140,6 +153,15 @@
|
|||||||
|
|
||||||
- (void)setAsMolecule {
|
- (void)setAsMolecule {
|
||||||
self.updateViewHorizontalDefaults = YES;
|
self.updateViewHorizontalDefaults = YES;
|
||||||
|
[self.molecule setAsMolecule];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
|
||||||
|
[super setWithJSON:json delegateObject:delegateObject additionalData:additionalData];
|
||||||
|
if (self.molecule) {
|
||||||
|
[self.molecule setWithJSON:json delegateObject:delegateObject additionalData:additionalData];
|
||||||
|
self.backgroundColor = self.molecule.backgroundColor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -48,7 +48,7 @@
|
|||||||
if (class) {
|
if (class) {
|
||||||
UIView <MVMCoreUIMoleculeViewProtocol>*view = [[class alloc] init];
|
UIView <MVMCoreUIMoleculeViewProtocol>*view = [[class alloc] init];
|
||||||
if ([view respondsToSelector:@selector(needsToBeConstrained)] && [view needsToBeConstrained]) {
|
if ([view respondsToSelector:@selector(needsToBeConstrained)] && [view needsToBeConstrained]) {
|
||||||
view = [[ConstrainingMoleculeView alloc] initWithMolecule:view];
|
view = [[ViewConstrainingView alloc] initWithMolecule:view];
|
||||||
}
|
}
|
||||||
if ([view respondsToSelector:@selector(setAsMolecule)]) {
|
if ([view respondsToSelector:@selector(setAsMolecule)]) {
|
||||||
[view setAsMolecule];
|
[view setAsMolecule];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user