mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 01:22:46 +02:00
Organize views by feature
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
Copyright 2016 OpenMarket Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import <MatrixKit/MatrixKit.h>
|
||||
|
||||
@interface TableViewCellWithCheckBoxAndLabel : MXKTableViewCell
|
||||
|
||||
@property (strong, nonatomic) IBOutlet UIImageView *checkBox;
|
||||
@property (strong, nonatomic) IBOutlet UILabel *label;
|
||||
|
||||
@property (nonatomic, getter=isEnabled) BOOL enabled;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *checkBoxLeadingConstraint;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright 2016 OpenMarket Ltd
|
||||
Copyright 2017 Vector Creations Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "TableViewCellWithCheckBoxAndLabel.h"
|
||||
|
||||
#import "RiotDesignValues.h"
|
||||
|
||||
@implementation TableViewCellWithCheckBoxAndLabel
|
||||
|
||||
- (void)customizeTableViewCellRendering
|
||||
{
|
||||
[super customizeTableViewCellRendering];
|
||||
|
||||
_label.textColor = kRiotPrimaryTextColor;
|
||||
}
|
||||
|
||||
- (void)setEnabled:(BOOL)enabled
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
_checkBox.image = [UIImage imageNamed:@"selection_tick"];
|
||||
}
|
||||
else
|
||||
{
|
||||
_checkBox.image = [UIImage imageNamed:@"selection_untick"];
|
||||
}
|
||||
|
||||
_enabled = enabled;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1108" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
|
||||
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="aCf-VI-ocb" customClass="TableViewCellWithCheckBoxAndLabel">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="aCf-VI-ocb" id="Eg5-vl-rni">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="selection_untick.png" translatesAutoresizingMaskIntoConstraints="NO" id="2Q4-aT-dLb">
|
||||
<rect key="frame" x="14" y="11" width="22" height="22"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="CheckBox"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="22" id="5Cp-Fp-6bx"/>
|
||||
<constraint firstAttribute="height" constant="22" id="XT4-aX-2aO"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Xx4-AP-OQs">
|
||||
<rect key="frame" x="46" y="11" width="42" height="21"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="Label"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="2Q4-aT-dLb" firstAttribute="leading" secondItem="Eg5-vl-rni" secondAttribute="leading" constant="14" id="3Th-py-oa7"/>
|
||||
<constraint firstItem="Xx4-AP-OQs" firstAttribute="leading" secondItem="2Q4-aT-dLb" secondAttribute="trailing" constant="10" id="6v0-PW-TqF"/>
|
||||
<constraint firstItem="2Q4-aT-dLb" firstAttribute="centerY" secondItem="Eg5-vl-rni" secondAttribute="centerY" id="7WY-jC-jXB"/>
|
||||
<constraint firstItem="Xx4-AP-OQs" firstAttribute="centerY" secondItem="Eg5-vl-rni" secondAttribute="centerY" id="Kf8-5v-riS"/>
|
||||
<constraint firstItem="Xx4-AP-OQs" firstAttribute="top" secondItem="Eg5-vl-rni" secondAttribute="topMargin" constant="3" id="VAD-zR-M7e"/>
|
||||
<constraint firstAttribute="bottomMargin" secondItem="Xx4-AP-OQs" secondAttribute="bottom" constant="3.5" id="f0y-Ra-PDl"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="Xx4-AP-OQs" secondAttribute="trailing" constant="15" id="nft-Mc-NNN"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<accessibility key="accessibilityConfiguration" identifier="TableViewCell"/>
|
||||
<connections>
|
||||
<outlet property="checkBox" destination="2Q4-aT-dLb" id="Rh8-NI-beY"/>
|
||||
<outlet property="checkBoxLeadingConstraint" destination="3Th-py-oa7" id="CpM-em-CVk"/>
|
||||
<outlet property="label" destination="Xx4-AP-OQs" id="9lG-Ne-bbb"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="selection_untick.png" width="22" height="22"/>
|
||||
</resources>
|
||||
</document>
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
Copyright 2016 OpenMarket Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import <MatrixKit/MatrixKit.h>
|
||||
|
||||
@class TableViewCellWithCheckBoxes;
|
||||
|
||||
/**
|
||||
`TableViewCellWithCheckBoxes` delegate.
|
||||
*/
|
||||
@protocol TableViewCellWithCheckBoxesDelegate <NSObject>
|
||||
|
||||
/**
|
||||
Tells the delegate that the user taps on a check box.
|
||||
|
||||
@param tableViewCellWithCheckBoxes the `TableViewCellWithCheckBoxes` instance.
|
||||
@param index the index of the concerned check box.
|
||||
*/
|
||||
- (void)tableViewCellWithCheckBoxes:(TableViewCellWithCheckBoxes *)tableViewCellWithCheckBoxes didTapOnCheckBoxAtIndex:(NSUInteger)index;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
'TableViewCellWithCheckBoxes' inherits 'MXKTableViewCell' class.
|
||||
It displays several options in a UITableViewCell. Each option has its own check box and its label.
|
||||
All option have the same width and they are horizontally aligned inside the main container.
|
||||
They are vertically centered.
|
||||
*/
|
||||
@interface TableViewCellWithCheckBoxes : MXKTableViewCell
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIView *mainContainer;
|
||||
|
||||
/**
|
||||
The number of boxes
|
||||
*/
|
||||
@property (nonatomic) NSUInteger checkBoxesNumber;
|
||||
|
||||
/**
|
||||
The current array of checkBoxes
|
||||
*/
|
||||
@property (nonatomic, readonly) NSArray<UIImageView*> *checkBoxes;
|
||||
|
||||
/**
|
||||
The current array of labels
|
||||
*/
|
||||
@property (nonatomic, readonly) NSArray<UILabel*> *labels;
|
||||
|
||||
/**
|
||||
Leading/Trailing constraints define here spacing to nearest neighbor (no relative to margin)
|
||||
*/
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *mainContainerLeadingConstraint;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *mainContainerTrailingConstraint;
|
||||
|
||||
/**
|
||||
The delegate for the cell.
|
||||
*/
|
||||
@property (nonatomic, weak) id<TableViewCellWithCheckBoxesDelegate> delegate;
|
||||
|
||||
/**
|
||||
Default is NO. Controls whether multiple check boxes can be selected simultaneously
|
||||
*/
|
||||
@property (nonatomic) BOOL allowsMultipleSelection;
|
||||
|
||||
/**
|
||||
Select or unselect a check box.
|
||||
If multiple selection is not allowed, this method unselect the current selected box in case of a new selection.
|
||||
|
||||
@param isSelected the new value of the check box.
|
||||
@param index the index of the check box.
|
||||
*/
|
||||
- (void)setCheckBoxValue:(BOOL)isSelected atIndex:(NSUInteger)index;
|
||||
|
||||
/**
|
||||
Get the current state of a check box
|
||||
*/
|
||||
- (BOOL)checkBoxValueAtIndex:(NSUInteger)index;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,313 @@
|
||||
/*
|
||||
Copyright 2016 OpenMarket Ltd
|
||||
Copyright 2017 Vector Creations Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "TableViewCellWithCheckBoxes.h"
|
||||
|
||||
// The space between 2 check boxes
|
||||
#define TABLEVIEWCELLWITHCHECKBOXES_MARGIN 8
|
||||
|
||||
@interface TableViewCellWithCheckBoxes ()
|
||||
{
|
||||
NSMutableArray *checkBoxesArray;
|
||||
NSMutableArray *labelArray;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TableViewCellWithCheckBoxes
|
||||
|
||||
- (void)setCheckBoxesNumber:(NSUInteger)checkBoxesNumber
|
||||
{
|
||||
if (_checkBoxesNumber == checkBoxesNumber)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove existing items
|
||||
NSArray *subviews = self.mainContainer.subviews;
|
||||
for (UIView *view in subviews)
|
||||
{
|
||||
[view removeFromSuperview];
|
||||
}
|
||||
|
||||
_checkBoxesNumber = checkBoxesNumber;
|
||||
|
||||
if (!_checkBoxesNumber)
|
||||
{
|
||||
// Nothing to do
|
||||
return;
|
||||
}
|
||||
|
||||
checkBoxesArray = [NSMutableArray arrayWithCapacity:checkBoxesNumber];
|
||||
labelArray = [NSMutableArray arrayWithCapacity:checkBoxesNumber];
|
||||
|
||||
CGFloat containerWidth = (self.mainContainer.frame.size.width - ((checkBoxesNumber - 1.0) * TABLEVIEWCELLWITHCHECKBOXES_MARGIN)) / checkBoxesNumber;
|
||||
|
||||
UIView *previousContainer = nil;
|
||||
NSLayoutConstraint *topConstraint, *leftConstraint, *bottomConstraint;
|
||||
NSLayoutConstraint *widthConstraint, *heightConstraint, *centerYConstraint, *centerXConstraint;
|
||||
|
||||
for (NSInteger index = 0; index < checkBoxesNumber; index++)
|
||||
{
|
||||
UIView *checkboxContainer = [[UIView alloc] initWithFrame:CGRectMake(index * (containerWidth + TABLEVIEWCELLWITHCHECKBOXES_MARGIN), 0, containerWidth, self.mainContainer.frame.size.height)];
|
||||
checkboxContainer.backgroundColor = [UIColor clearColor];
|
||||
[self.mainContainer addSubview:checkboxContainer];
|
||||
|
||||
// Add container constraints
|
||||
checkboxContainer.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
if (!previousContainer)
|
||||
{
|
||||
leftConstraint = [NSLayoutConstraint constraintWithItem:checkboxContainer
|
||||
attribute:NSLayoutAttributeLeading
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:self.mainContainer
|
||||
attribute:NSLayoutAttributeLeading
|
||||
multiplier:1
|
||||
constant:0];
|
||||
widthConstraint = [NSLayoutConstraint constraintWithItem:checkboxContainer
|
||||
attribute:NSLayoutAttributeWidth
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:self.mainContainer
|
||||
attribute:NSLayoutAttributeWidth
|
||||
multiplier:(1.0 / checkBoxesNumber)
|
||||
constant:(- ((checkBoxesNumber - 1.0) * TABLEVIEWCELLWITHCHECKBOXES_MARGIN) / checkBoxesNumber)];
|
||||
}
|
||||
else
|
||||
{
|
||||
leftConstraint = [NSLayoutConstraint constraintWithItem:checkboxContainer
|
||||
attribute:NSLayoutAttributeLeading
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:previousContainer
|
||||
attribute:NSLayoutAttributeTrailing
|
||||
multiplier:1
|
||||
constant:TABLEVIEWCELLWITHCHECKBOXES_MARGIN];
|
||||
widthConstraint = [NSLayoutConstraint constraintWithItem:checkboxContainer
|
||||
attribute:NSLayoutAttributeWidth
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:previousContainer
|
||||
attribute:NSLayoutAttributeWidth
|
||||
multiplier:1
|
||||
constant:0];
|
||||
}
|
||||
|
||||
topConstraint = [NSLayoutConstraint constraintWithItem:checkboxContainer
|
||||
attribute:NSLayoutAttributeTop
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:self.mainContainer
|
||||
attribute:NSLayoutAttributeTop
|
||||
multiplier:1
|
||||
constant:0];
|
||||
|
||||
bottomConstraint = [NSLayoutConstraint constraintWithItem:checkboxContainer
|
||||
attribute:NSLayoutAttributeBottom
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:self.mainContainer
|
||||
attribute:NSLayoutAttributeBottom
|
||||
multiplier:1
|
||||
constant:0];
|
||||
|
||||
[NSLayoutConstraint activateConstraints:@[leftConstraint, widthConstraint, topConstraint, bottomConstraint]];
|
||||
|
||||
previousContainer = checkboxContainer;
|
||||
|
||||
// Add Checkbox and Label
|
||||
UIImageView *checkbox = [[UIImageView alloc] initWithFrame:CGRectMake(14, 11, 22, 22)];
|
||||
checkbox.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[checkboxContainer addSubview:checkbox];
|
||||
|
||||
// Store the new check box unselected by default
|
||||
checkbox.image = [UIImage imageNamed:@"selection_untick"];
|
||||
checkbox.tag = 0;
|
||||
[checkBoxesArray addObject:checkbox];
|
||||
|
||||
UILabel *theLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 0, containerWidth - 60, 31)];
|
||||
theLabel.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[checkboxContainer addSubview:theLabel];
|
||||
[labelArray addObject:theLabel];
|
||||
|
||||
UIView *checkboxMask = [[UIView alloc] initWithFrame:CGRectMake(7, 4, 36, 36)];
|
||||
checkboxMask.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[checkboxContainer addSubview:checkboxMask];
|
||||
// Listen to check box tap
|
||||
checkboxMask.tag = index;
|
||||
checkboxMask.userInteractionEnabled = YES;
|
||||
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onCheckBoxTap:)];
|
||||
[tapGesture setNumberOfTouchesRequired:1];
|
||||
[tapGesture setNumberOfTapsRequired:1];
|
||||
[tapGesture setDelegate:self];
|
||||
[checkboxMask addGestureRecognizer:tapGesture];
|
||||
|
||||
// Add switch constraints
|
||||
leftConstraint = [NSLayoutConstraint constraintWithItem:checkbox
|
||||
attribute:NSLayoutAttributeLeading
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:checkboxContainer
|
||||
attribute:NSLayoutAttributeLeading
|
||||
multiplier:1
|
||||
constant:14];
|
||||
|
||||
widthConstraint = [NSLayoutConstraint constraintWithItem:checkbox
|
||||
attribute:NSLayoutAttributeWidth
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:nil
|
||||
attribute:NSLayoutAttributeNotAnAttribute
|
||||
multiplier:1
|
||||
constant:22];
|
||||
|
||||
centerYConstraint = [NSLayoutConstraint constraintWithItem:checkbox
|
||||
attribute:NSLayoutAttributeCenterY
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:checkboxContainer
|
||||
attribute:NSLayoutAttributeCenterY
|
||||
multiplier:1
|
||||
constant:0.0f];
|
||||
|
||||
[NSLayoutConstraint activateConstraints:@[leftConstraint, widthConstraint, centerYConstraint]];
|
||||
|
||||
|
||||
// Add Label constraints
|
||||
topConstraint = [NSLayoutConstraint constraintWithItem:theLabel
|
||||
attribute:NSLayoutAttributeTop
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:checkboxContainer
|
||||
attribute:NSLayoutAttributeTop
|
||||
multiplier:1
|
||||
constant:0];
|
||||
|
||||
leftConstraint = [NSLayoutConstraint constraintWithItem:theLabel
|
||||
attribute:NSLayoutAttributeLeading
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:checkbox
|
||||
attribute:NSLayoutAttributeTrailing
|
||||
multiplier:1
|
||||
constant:9];
|
||||
|
||||
centerYConstraint = [NSLayoutConstraint constraintWithItem:theLabel
|
||||
attribute:NSLayoutAttributeCenterY
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:checkboxContainer
|
||||
attribute:NSLayoutAttributeCenterY
|
||||
multiplier:1
|
||||
constant:0.0f];
|
||||
|
||||
[NSLayoutConstraint activateConstraints:@[topConstraint, leftConstraint, centerYConstraint]];
|
||||
|
||||
// Add check box mask constraints
|
||||
widthConstraint = [NSLayoutConstraint constraintWithItem:checkboxMask
|
||||
attribute:NSLayoutAttributeWidth
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:nil
|
||||
attribute:NSLayoutAttributeNotAnAttribute
|
||||
multiplier:1
|
||||
constant:36];
|
||||
|
||||
heightConstraint = [NSLayoutConstraint constraintWithItem:checkboxMask
|
||||
attribute:NSLayoutAttributeHeight
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:nil
|
||||
attribute:NSLayoutAttributeNotAnAttribute
|
||||
multiplier:1
|
||||
constant:36];
|
||||
|
||||
centerXConstraint = [NSLayoutConstraint constraintWithItem:checkboxMask
|
||||
attribute:NSLayoutAttributeCenterX
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:checkbox
|
||||
attribute:NSLayoutAttributeCenterX
|
||||
multiplier:1
|
||||
constant:0.0f];
|
||||
|
||||
centerYConstraint = [NSLayoutConstraint constraintWithItem:checkboxMask
|
||||
attribute:NSLayoutAttributeCenterY
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:checkbox
|
||||
attribute:NSLayoutAttributeCenterY
|
||||
multiplier:1
|
||||
constant:0.0f];
|
||||
|
||||
[NSLayoutConstraint activateConstraints:@[widthConstraint, heightConstraint, centerXConstraint, centerYConstraint]];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray*)checkBoxes
|
||||
{
|
||||
return [NSArray arrayWithArray:checkBoxesArray];
|
||||
}
|
||||
|
||||
- (NSArray*)labels
|
||||
{
|
||||
return [NSArray arrayWithArray:labelArray];
|
||||
}
|
||||
|
||||
- (void)setCheckBoxValue:(BOOL)isSelected atIndex:(NSUInteger)index
|
||||
{
|
||||
if (index < checkBoxesArray.count)
|
||||
{
|
||||
UIImageView *checkBox = checkBoxesArray[index];
|
||||
|
||||
if (isSelected && !checkBox.tag)
|
||||
{
|
||||
checkBox.image = [UIImage imageNamed:@"selection_tick"];
|
||||
checkBox.tag = 1;
|
||||
|
||||
if (!self.allowsMultipleSelection)
|
||||
{
|
||||
// Unselect others check boxes
|
||||
for (NSUInteger k = 0; k < checkBoxesArray.count; k++)
|
||||
{
|
||||
if (k != index)
|
||||
{
|
||||
checkBox = checkBoxesArray[k];
|
||||
if (checkBox.tag)
|
||||
{
|
||||
checkBox.image = [UIImage imageNamed:@"selection_untick"];
|
||||
checkBox.tag = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!isSelected && checkBox.tag)
|
||||
{
|
||||
checkBox.image = [UIImage imageNamed:@"selection_untick"];
|
||||
checkBox.tag = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)checkBoxValueAtIndex:(NSUInteger)index
|
||||
{
|
||||
if (index < checkBoxesArray.count)
|
||||
{
|
||||
UIImageView *checkBox = checkBoxesArray[index];
|
||||
|
||||
return ((BOOL)checkBox.tag);
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
#pragma mark - Action
|
||||
|
||||
- (IBAction)onCheckBoxTap:(UITapGestureRecognizer*)sender
|
||||
{
|
||||
if (_delegate)
|
||||
{
|
||||
[_delegate tableViewCellWithCheckBoxes:self didTapOnCheckBoxAtIndex:sender.view.tag];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="20U-7H-xmi" customClass="TableViewCellWithCheckBoxes">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="20U-7H-xmi" id="cFw-g7-Cgn">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hGF-Ge-C0t">
|
||||
<rect key="frame" x="15" y="6" width="570" height="31"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="31" id="JHe-A2-qQn"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="hGF-Ge-C0t" firstAttribute="leading" secondItem="cFw-g7-Cgn" secondAttribute="leading" constant="15" id="hl1-17-xPW"/>
|
||||
<constraint firstItem="hGF-Ge-C0t" firstAttribute="centerY" secondItem="cFw-g7-Cgn" secondAttribute="centerY" id="lvp-ia-Agx"/>
|
||||
<constraint firstAttribute="trailing" secondItem="hGF-Ge-C0t" secondAttribute="trailing" constant="15" id="njm-cy-8WD"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<accessibility key="accessibilityConfiguration" identifier="TableViewCell"/>
|
||||
<connections>
|
||||
<outlet property="mainContainer" destination="hGF-Ge-C0t" id="ozw-BB-s9o"/>
|
||||
<outlet property="mainContainerLeadingConstraint" destination="hl1-17-xPW" id="PMX-A4-OXZ"/>
|
||||
<outlet property="mainContainerTrailingConstraint" destination="njm-cy-8WD" id="T1O-tz-J6b"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
</document>
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
Copyright 2015 OpenMarket Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import <MatrixKit/MatrixKit.h>
|
||||
|
||||
@interface TableViewCellWithLabelAndLargeTextView : MXKTableViewCell <UITextViewDelegate>
|
||||
|
||||
@property (strong, nonatomic) IBOutlet UILabel *label;
|
||||
@property (strong, nonatomic) IBOutlet UITextView *textView;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *labelTrailingMinConstraint;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *labelLeadingConstraint;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *textViewWidthConstraint;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *textViewTrailingConstraint;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
Copyright 2015 OpenMarket Ltd
|
||||
Copyright 2017 Vector Creations Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "TableViewCellWithLabelAndLargeTextView.h"
|
||||
|
||||
#import "RiotDesignValues.h"
|
||||
|
||||
@implementation TableViewCellWithLabelAndLargeTextView
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
[super awakeFromNib];
|
||||
|
||||
// Adjust text view
|
||||
// Remove the container inset: this operation impacts only the vertical margin.
|
||||
// Reset textContainer.lineFragmentPadding to remove horizontal margin.
|
||||
_textView.textContainerInset = UIEdgeInsetsZero;
|
||||
_textView.textContainer.lineFragmentPadding = 0;
|
||||
}
|
||||
|
||||
- (void)customizeTableViewCellRendering
|
||||
{
|
||||
[super customizeTableViewCellRendering];
|
||||
|
||||
_label.textColor = kRiotPrimaryTextColor;
|
||||
_textView.textColor = kRiotPrimaryTextColor;
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
|
||||
CGFloat cellWidth = self.contentView.frame.size.width;
|
||||
|
||||
CGRect frame = _label.frame;
|
||||
CGFloat minTextViewPosX = frame.origin.x + frame.size.width + _labelTrailingMinConstraint.constant;
|
||||
|
||||
CGFloat maxTextViewWidth = cellWidth - minTextViewPosX - _textViewTrailingConstraint.constant;
|
||||
|
||||
if (_textView.isEditable && _textView.isFirstResponder)
|
||||
{
|
||||
// Use the full available width when the field is edited
|
||||
_textViewWidthConstraint.constant = maxTextViewWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Adjust the text view width to display it on the right side of the cell
|
||||
CGSize size = _textView.frame.size;
|
||||
size.width = maxTextViewWidth;
|
||||
|
||||
size = [_textView sizeThatFits:size];
|
||||
|
||||
_textViewWidthConstraint.constant = size.width;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (void)textViewDidBeginEditing:(UITextView *)textView;
|
||||
{
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (void)textViewDidEndEditing:(UITextView *)textView
|
||||
{
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1108" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" rowHeight="124" id="5Je-1y-foH" customClass="TableViewCellWithLabelAndLargeTextView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="124"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="5Je-1y-foH" id="hCm-wd-Yup">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="123"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="justified" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="584" translatesAutoresizingMaskIntoConstraints="NO" id="DE7-uC-Oz2">
|
||||
<rect key="frame" x="15" y="12" width="42" height="21"/>
|
||||
<color key="tintColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="Label"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" text="a text" translatesAutoresizingMaskIntoConstraints="NO" id="6xh-yB-9FP">
|
||||
<rect key="frame" x="532" y="12" width="53" height="100"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="TextView"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="53" id="Nrj-Yh-zMx"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="5Je-1y-foH" id="wnl-hm-OTD"/>
|
||||
</connections>
|
||||
</textView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="6xh-yB-9FP" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="DE7-uC-Oz2" secondAttribute="trailing" constant="16" id="oCm-jb-bm0"/>
|
||||
<constraint firstItem="DE7-uC-Oz2" firstAttribute="leading" secondItem="hCm-wd-Yup" secondAttribute="leading" constant="15" id="qse-r7-x6e"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<accessibility key="accessibilityConfiguration" identifier="TableViewCell"/>
|
||||
<constraints>
|
||||
<constraint firstItem="DE7-uC-Oz2" firstAttribute="top" secondItem="5Je-1y-foH" secondAttribute="top" constant="12" id="4gW-jW-XUX"/>
|
||||
<constraint firstAttribute="bottom" secondItem="6xh-yB-9FP" secondAttribute="bottom" constant="12" id="Io9-HP-DJE"/>
|
||||
<constraint firstItem="6xh-yB-9FP" firstAttribute="top" secondItem="5Je-1y-foH" secondAttribute="top" constant="12" id="PqJ-jG-FUv"/>
|
||||
<constraint firstAttribute="trailing" secondItem="6xh-yB-9FP" secondAttribute="trailing" constant="15" id="hIh-cS-5Lj"/>
|
||||
</constraints>
|
||||
<connections>
|
||||
<outlet property="label" destination="DE7-uC-Oz2" id="xmR-kD-5aJ"/>
|
||||
<outlet property="labelLeadingConstraint" destination="qse-r7-x6e" id="MaG-lx-KhS"/>
|
||||
<outlet property="labelTrailingMinConstraint" destination="oCm-jb-bm0" id="tK1-sl-BS3"/>
|
||||
<outlet property="textView" destination="6xh-yB-9FP" id="dus-5x-CwT"/>
|
||||
<outlet property="textViewTrailingConstraint" destination="hIh-cS-5Lj" id="iVx-5Q-LSe"/>
|
||||
<outlet property="textViewWidthConstraint" destination="Nrj-Yh-zMx" id="Bws-Zg-agY"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
</document>
|
||||
Reference in New Issue
Block a user