Skip to content

Commit

Permalink
[scribe-org#330] Add a dedicated cell for About tab
Browse files Browse the repository at this point in the history
  • Loading branch information
damien-rivet committed Nov 20, 2023
1 parent 8cbdd5e commit fe96dcc
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 34 deletions.
16 changes: 16 additions & 0 deletions Scribe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,8 @@
D1CDEDDC2A85AE9D00098546 /* NBInterfaceVariables.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1CDED802A85A12400098546 /* NBInterfaceVariables.swift */; };
D1F0367227AAE12200CD7921 /* InterfaceVariables.swift in Sources */ = {isa = PBXBuildFile; fileRef = D190B2492741B31F00705659 /* InterfaceVariables.swift */; };
D1F0367327AAE1B400CD7921 /* CommandVariables.swift in Sources */ = {isa = PBXBuildFile; fileRef = D190B2462741B24F00705659 /* CommandVariables.swift */; };
ED2486F32B0B4E8C0038AE6A /* AboutTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED2486F12B0B4E8C0038AE6A /* AboutTableViewCell.swift */; };
ED2486F42B0B4E8C0038AE6A /* AboutTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = ED2486F22B0B4E8C0038AE6A /* AboutTableViewCell.xib */; };
EDB4601B2AF9FD8200BEA967 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = EDB4601A2AF9FD8200BEA967 /* Localizable.xcstrings */; };
EDB460212B03B3E400BEA967 /* BaseTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDB460202B03B3E400BEA967 /* BaseTableViewController.swift */; };
EDC364692AE408F20001E456 /* InterfaceConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDC364682AE408F20001E456 /* InterfaceConstants.swift */; };
Expand Down Expand Up @@ -969,6 +971,8 @@
D1D8B23B2AE4089C0070B817 /* Italian.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Italian.entitlements; sourceTree = "<group>"; };
D1D8B23C2AE408AC0070B817 /* German.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = German.entitlements; sourceTree = "<group>"; };
D1D8B23D2AE408C50070B817 /* French.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = French.entitlements; sourceTree = "<group>"; };
ED2486F12B0B4E8C0038AE6A /* AboutTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutTableViewCell.swift; sourceTree = "<group>"; };
ED2486F22B0B4E8C0038AE6A /* AboutTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AboutTableViewCell.xib; sourceTree = "<group>"; };
EDB4601A2AF9FD8200BEA967 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
EDB4601C2AF9FDD600BEA967 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/AppScreen.strings; sourceTree = "<group>"; };
EDB4601D2AF9FDD600BEA967 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/LaunchScreen.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1092,6 +1096,7 @@
1406B7832A2DFCA2001DF45B /* Components */ = {
isa = PBXGroup;
children = (
ED2486F02B0B4E610038AE6A /* UITableViewCells */,
1406B7852A2DFCBE001DF45B /* InfoChildTableViewCell */,
140158A12A4EDB2200D14E52 /* TableViewTemplateViewController.swift */,
);
Expand Down Expand Up @@ -1468,6 +1473,15 @@
path = Keyboards;
sourceTree = "<group>";
};
ED2486F02B0B4E610038AE6A /* UITableViewCells */ = {
isa = PBXGroup;
children = (
ED2486F12B0B4E8C0038AE6A /* AboutTableViewCell.swift */,
ED2486F22B0B4E8C0038AE6A /* AboutTableViewCell.xib */,
);
path = UITableViewCells;
sourceTree = "<group>";
};
EDB4601F2B03B3B400BEA967 /* Views */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1834,6 +1848,7 @@
38BD214122D5908100C6795D /* LaunchScreen.storyboard in Resources */,
147797B12A2CD3370044A53E /* InfoChildTableViewCell.xib in Resources */,
EDB4601B2AF9FD8200BEA967 /* Localizable.xcstrings in Resources */,
ED2486F42B0B4E8C0038AE6A /* AboutTableViewCell.xib in Resources */,
38BD213922D5907F00C6795D /* AppScreen.storyboard in Resources */,
38BD213E22D5908100C6795D /* Assets.xcassets in Resources */,
);
Expand Down Expand Up @@ -2030,6 +2045,7 @@
D171942027AECD170038660B /* SVCommandVariables.swift in Sources */,
30453967293B9D31003AE55B /* ViewThemeable.swift in Sources */,
D1362A39274C106A00C00E48 /* ColorVariables.swift in Sources */,
ED2486F32B0B4E8C0038AE6A /* AboutTableViewCell.swift in Sources */,
D1A2DCB127AD37BD0057A10D /* ENAppText.swift in Sources */,
D1CDED832A85A12C00098546 /* NBCommandVariables.swift in Sources */,
D171944927AEF7290038660B /* KeyboardKeys.swift in Sources */,
Expand Down
4 changes: 3 additions & 1 deletion Scribe/AboutTab/AboutViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ final class AboutViewController: BaseTableViewController {
super.viewDidLoad()

title = "About"

tableView.register(UINib(nibName: "AboutTableViewCell", bundle: nil), forCellReuseIdentifier: AboutTableViewCell.reuseIdentifier)
}
}

Expand All @@ -37,7 +39,7 @@ final class AboutViewController: BaseTableViewController {
extension AboutViewController {

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: InfoChildTableViewCell.reuseIdentifier, for: indexPath) as! InfoChildTableViewCell
let cell = tableView.dequeueReusableCell(withIdentifier: AboutTableViewCell.reuseIdentifier, for: indexPath) as! AboutTableViewCell

cell.configureCell(for: dataSet[indexPath.section].section[indexPath.row])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ final class InfoChildTableViewCell: UITableViewCell {
@IBOutlet var containerView: UIView!
@IBOutlet var titleLabel: UILabel!
@IBOutlet var descriptionLabel: UILabel!
@IBOutlet var iconImageView: UIImageView!
@IBOutlet var chevronImgView: UIImageView!
@IBOutlet var toggleSwitch: UISwitch!

var section: Section?
Expand Down Expand Up @@ -47,17 +45,6 @@ final class InfoChildTableViewCell: UITableViewCell {

titleLabel.text = section.sectionTitle

if let icon = section.imageString {
iconImageView.image = UIImage.availableIconImage(with: icon)

containerView.addSubview(iconImageView)

} else {
iconImageView.image = nil

iconImageView.removeFromSuperview()
}

if let shortDescription = section.shortDescription {
descriptionLabel.text = shortDescription

Expand All @@ -72,7 +59,7 @@ final class InfoChildTableViewCell: UITableViewCell {
toggleSwitch.isHidden = true
} else {
accessoryType = .none
// chevronImgView.isHidden = true
toggleSwitch.isHidden = false
}

fetchSwitchStateForCell()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,8 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="l6P-p1-vZD">
<rect key="frame" x="0.0" y="0.0" width="424" height="128"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="JHo-c6-kU1">
<rect key="frame" x="16" y="16" width="26" height="26"/>
<color key="tintColor" name="keyChar"/>
<constraints>
<constraint firstAttribute="height" constant="26" id="bzN-eO-Qw2"/>
<constraint firstAttribute="width" constant="26" id="izd-eT-gcA"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XI7-83-3eC">
<rect key="frame" x="50" y="16" width="301" height="26"/>
<rect key="frame" x="16" y="61" width="335" height="26"/>
<constraints>
<constraint firstAttribute="height" constant="26" id="trX-iS-h3L"/>
</constraints>
Expand All @@ -40,7 +32,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LZg-In-Sru">
<rect key="frame" x="16" y="50" width="392" height="62"/>
<rect key="frame" x="16" y="91" width="392" height="21"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="21" id="h5P-Y8-JKH"/>
</constraints>
Expand All @@ -49,7 +41,7 @@
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="FbK-yb-cab">
<rect key="frame" x="359" y="13.666666666666664" width="51" height="31"/>
<rect key="frame" x="359" y="58.666666666666657" width="51" height="31"/>
<constraints>
<constraint firstAttribute="width" constant="49" id="TLe-pF-eis"/>
</constraints>
Expand All @@ -63,13 +55,9 @@
<constraints>
<constraint firstAttribute="trailing" secondItem="FbK-yb-cab" secondAttribute="trailing" constant="16" id="3s0-Zw-YSj"/>
<constraint firstItem="LZg-In-Sru" firstAttribute="leading" secondItem="l6P-p1-vZD" secondAttribute="leading" constant="16" id="71k-Bj-KYB"/>
<constraint firstItem="JHo-c6-kU1" firstAttribute="top" secondItem="l6P-p1-vZD" secondAttribute="top" constant="16" id="Cbh-DW-DpW"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="XI7-83-3eC" secondAttribute="bottom" constant="16" id="PXy-LD-usI"/>
<constraint firstItem="XI7-83-3eC" firstAttribute="leading" secondItem="l6P-p1-vZD" secondAttribute="leading" priority="900" constant="16" id="YYU-SX-n2Q"/>
<constraint firstItem="XI7-83-3eC" firstAttribute="centerY" secondItem="JHo-c6-kU1" secondAttribute="centerY" id="e4o-HJ-dvc"/>
<constraint firstItem="XI7-83-3eC" firstAttribute="leading" secondItem="JHo-c6-kU1" secondAttribute="trailing" constant="8" id="fPm-bp-an4"/>
<constraint firstItem="LZg-In-Sru" firstAttribute="top" secondItem="XI7-83-3eC" secondAttribute="bottom" constant="8" id="fZ2-aM-LoY"/>
<constraint firstItem="JHo-c6-kU1" firstAttribute="leading" secondItem="l6P-p1-vZD" secondAttribute="leading" constant="16" id="fjG-77-Yhh"/>
<constraint firstItem="LZg-In-Sru" firstAttribute="top" secondItem="XI7-83-3eC" secondAttribute="bottom" constant="4" id="fZ2-aM-LoY"/>
<constraint firstItem="FbK-yb-cab" firstAttribute="leading" secondItem="XI7-83-3eC" secondAttribute="trailing" constant="8" id="jLg-C9-5nA"/>
<constraint firstAttribute="bottom" secondItem="LZg-In-Sru" secondAttribute="bottom" constant="16" id="kOE-ta-dAg"/>
<constraint firstItem="XI7-83-3eC" firstAttribute="top" relation="greaterThanOrEqual" secondItem="l6P-p1-vZD" secondAttribute="top" constant="16" id="mSh-fL-RUI"/>
Expand All @@ -89,7 +77,6 @@
<connections>
<outlet property="containerView" destination="l6P-p1-vZD" id="4Tm-qb-JHB"/>
<outlet property="descriptionLabel" destination="LZg-In-Sru" id="M4c-Fh-6s1"/>
<outlet property="iconImageView" destination="JHo-c6-kU1" id="iTB-MV-z6M"/>
<outlet property="titleLabel" destination="XI7-83-3eC" id="8Oo-On-CWs"/>
<outlet property="toggleSwitch" destination="FbK-yb-cab" id="CYZ-wz-okM"/>
</connections>
Expand All @@ -101,7 +88,7 @@
<color red="0.0" green="0.0" blue="0.0" alpha="0.89999997615814209" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<systemColor name="secondaryLabelColor">
<color red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
Expand Down
49 changes: 49 additions & 0 deletions Scribe/Components/UITableViewCells/AboutTableViewCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// Copyright (C) 2023 Scribe
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

import UIKit

final class AboutTableViewCell: UITableViewCell {

// MARK: - Constants

static let reuseIdentifier = String(describing: InfoChildTableViewCell.self)

// MARK: - Properties

@IBOutlet var titleLabel: UILabel!
@IBOutlet var iconImageView: UIImageView!

var section: Section?
var parentSection: Section?

// MARK: - Functions

func configureCell(for section: Section) {
selectionStyle = .none

titleLabel.text = section.sectionTitle

if let icon = section.imageString {
iconImageView.image = UIImage.availableIconImage(with: icon)
iconImageView.constraints.forEach { $0.isActive = true }
} else {
iconImageView.image = nil
iconImageView.constraints.forEach { $0.isActive = false }
}
}
}
65 changes: 65 additions & 0 deletions Scribe/Components/UITableViewCells/AboutTableViewCell.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22155" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22131"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.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="default" indentationWidth="10" rowHeight="132" id="KGk-i7-Jjw" customClass="AboutTableViewCell" customModule="Scribe" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="486" height="132"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="486" height="132"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AJP-R8-VkX">
<rect key="frame" x="50" y="53" width="428" height="26"/>
<constraints>
<constraint firstAttribute="height" constant="26" id="W9s-aE-Zx6"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="16"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="MSu-WY-MCY">
<rect key="frame" x="16" y="53" width="26" height="26"/>
<color key="tintColor" name="keyChar"/>
<constraints>
<constraint firstAttribute="width" constant="26" id="Fay-e2-5uF"/>
<constraint firstAttribute="height" constant="26" id="Vwp-c3-IiP"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="MSu-WY-MCY" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="6Yr-Bm-4Cx"/>
<constraint firstItem="MSu-WY-MCY" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="k6M-7f-ePY"/>
<constraint firstItem="AJP-R8-VkX" firstAttribute="centerY" secondItem="MSu-WY-MCY" secondAttribute="centerY" id="twY-UQ-o7I"/>
<constraint firstItem="AJP-R8-VkX" firstAttribute="leading" secondItem="MSu-WY-MCY" secondAttribute="trailing" constant="8" id="udY-dz-eEL"/>
<constraint firstAttribute="trailing" secondItem="AJP-R8-VkX" secondAttribute="trailing" constant="8" id="wI4-UY-kS6"/>
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<connections>
<outlet property="iconImageView" destination="MSu-WY-MCY" id="EMy-K1-jZa"/>
<outlet property="titleLabel" destination="AJP-R8-VkX" id="urL-z2-Msc"/>
</connections>
<point key="canvasLocation" x="265.64885496183206" y="50.70422535211268"/>
</tableViewCell>
</objects>
<resources>
<namedColor name="keyChar">
<color red="0.0" green="0.0" blue="0.0" alpha="0.89999997615814209" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
Loading

0 comments on commit fe96dcc

Please sign in to comment.