mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-18 05:33:32 +02:00
Add the tableview line separators.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
#import "TableViewCellWithLabelAndTextField.h"
|
||||
#import "TableViewCellWithLabelAndLargeTextView.h"
|
||||
#import "TableViewCellSeparator.h"
|
||||
|
||||
#define ROOM_SECTION 0
|
||||
|
||||
@@ -91,7 +92,8 @@
|
||||
{
|
||||
if (section == ROOM_SECTION)
|
||||
{
|
||||
return ROOM_SECTION_COUNT;
|
||||
// add separators
|
||||
return ROOM_SECTION_COUNT * 2 + 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -115,10 +117,21 @@
|
||||
{
|
||||
if (indexPath.section == ROOM_SECTION)
|
||||
{
|
||||
if (indexPath.row == ROOM_SECTION_TOPIC)
|
||||
{
|
||||
return ROOM_TOPIC_CELL_HEIGHT;
|
||||
}
|
||||
NSInteger row = indexPath.row;
|
||||
|
||||
// is a separator ?
|
||||
if ((row % 2) == 0)
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
// retrieve row as a ROOM_SECTION_XX index
|
||||
row = (row - 1) / 2;
|
||||
|
||||
if (row == ROOM_SECTION_TOPIC)
|
||||
{
|
||||
return ROOM_TOPIC_CELL_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
return [super tableView:tableView heightForRowAtIndexPath:indexPath];
|
||||
@@ -126,12 +139,31 @@
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
NSInteger row = indexPath.row;
|
||||
UITableViewCell* cell = nil;
|
||||
|
||||
// general settings
|
||||
if (indexPath.section == ROOM_SECTION)
|
||||
{
|
||||
if (indexPath.row == ROOM_SECTION_TOPIC)
|
||||
if ((row % 2) == 0)
|
||||
{
|
||||
UITableViewCell* sepCell = [tableView dequeueReusableCellWithIdentifier:[TableViewCellSeparator defaultReuseIdentifier]];
|
||||
|
||||
if (!sepCell)
|
||||
{
|
||||
sepCell = [[TableViewCellSeparator alloc] init];
|
||||
}
|
||||
|
||||
// the borders are drawn in dark grey
|
||||
sepCell.contentView.backgroundColor = ((row == 0) || (row == ROOM_SECTION_COUNT * 2)) ? [UIColor darkGrayColor] : [UIColor lightGrayColor];
|
||||
|
||||
return sepCell;
|
||||
}
|
||||
|
||||
// retrieve row as a ROOM_SECTION_XX index
|
||||
row = (row - 1) / 2;
|
||||
|
||||
if (row == ROOM_SECTION_TOPIC)
|
||||
{
|
||||
TableViewCellWithLabelAndLargeTextView *roomTopicCell = [tableView dequeueReusableCellWithIdentifier:[TableViewCellWithLabelAndLargeTextView defaultReuseIdentifier]];
|
||||
|
||||
@@ -165,7 +197,7 @@
|
||||
|
||||
cell = roomTopicCell;
|
||||
}
|
||||
else if (indexPath.row == ROOM_SECTION_NAME)
|
||||
else if (row == ROOM_SECTION_NAME)
|
||||
{
|
||||
TableViewCellWithLabelAndTextField *roomNameCell = [tableView dequeueReusableCellWithIdentifier:[TableViewCellWithLabelAndTextField defaultReuseIdentifier]];
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
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 "MXKTableViewCell.h"
|
||||
|
||||
@interface TableViewCellSeparator : MXKTableViewCell
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
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 "TableViewCellSeparator.h"
|
||||
|
||||
@implementation TableViewCellSeparator
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
|
||||
</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="2" id="5Je-1y-foH" customClass="TableViewCellSeparator">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="2"/>
|
||||
<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="1"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<color key="backgroundColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="tintColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
</document>
|
||||
@@ -18,18 +18,9 @@
|
||||
|
||||
@interface TableViewCellWithLabelAndLargeTextView : MXKTableViewCell
|
||||
{
|
||||
@protected
|
||||
UIView *inputAccessoryView;
|
||||
}
|
||||
|
||||
@property (strong, nonatomic) IBOutlet UILabel *mxkLabel;
|
||||
@property (strong, nonatomic) IBOutlet UITextView *mxkTextView;
|
||||
|
||||
/**
|
||||
The custom accessory view associated with the text field. This view is
|
||||
actually used to retrieve the keyboard view. Indeed the keyboard view is the superview of
|
||||
the accessory view when the text field become the first responder.
|
||||
*/
|
||||
@property (readonly) UIView *inputAccessoryView;
|
||||
|
||||
@end
|
||||
@@ -17,16 +17,12 @@
|
||||
#import "TableViewCellWithLabelAndLargeTextView.h"
|
||||
|
||||
@implementation TableViewCellWithLabelAndLargeTextView
|
||||
@synthesize inputAccessoryView;
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
||||
{
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self)
|
||||
{
|
||||
// Add an accessory view to the text view in order to retrieve keyboard view.
|
||||
//inputAccessoryView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
//_mxkTextView.inputAccessoryView = inputAccessoryView;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -34,7 +30,6 @@
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
//inputAccessoryView = nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user