Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Scribe/SettingsTab/SettingsTableData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ enum SettingsTableData {
shortDescription: NSLocalizedString("i18n.app.settings.keyboard.functionality.auto_suggest_emoji_description", value: "Turn on emoji suggestions and completions for more expressive typing.", comment: "")
),
Section(
sectionTitle: NSLocalizedString("i18n.app.word_for_word", value: "Word for word deletion on long press", comment: ""),
sectionTitle: NSLocalizedString("i18n.app.settings.keyboard.functionality.delete_word_by_word", value: "Word for word deletion on long press", comment: ""),
hasToggle: true,
sectionState: .none(.toggleWordForWordDeletion),
shortDescription: NSLocalizedString("i18n.app.word_for_word.description", value: "Word for word deletion.", comment: "")
shortDescription: NSLocalizedString("i18n.app.settings.keyboard.functionality.delete_word_by_word_description", value: "Delete text word by word when the delete key is pressed and held.", comment: "")
)
],
hasDynamicData: nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
<rect key="frame" x="0.0" y="0.0" width="424" height="148"/>
<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="XI7-83-3eC" userLabel="TitleLabelPad">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XI7-83-3eC" userLabel="TitleLabelPad">
<rect key="frame" x="24.000000000000004" y="12" width="58.333333333333343" height="42"/>
<constraints>
<constraint firstAttribute="height" constant="42" id="trX-iS-h3L"/>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="42" id="trX-iS-h3L"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="24"/>
<color key="textColor" name="keyChar"/>
Expand All @@ -44,7 +44,7 @@
<action selector="switchDidChange:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="9ge-t9-By6"/>
</connections>
</switch>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LZg-In-Sru" userLabel="DescriptionLabelPad">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LZg-In-Sru" userLabel="DescriptionLabelPad">
<rect key="frame" x="24" y="62" width="376" height="70"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="21" id="h5P-Y8-JKH"/>
Expand All @@ -53,10 +53,10 @@
<color key="textColor" systemColor="secondaryLabelColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Y7l-w6-QQi" userLabel="TitleLabelPhone">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Y7l-w6-QQi" userLabel="TitleLabelPhone">
<rect key="frame" x="15.999999999999996" y="8" width="40.666666666666657" height="28"/>
<constraints>
<constraint firstAttribute="height" constant="28" id="FRe-ww-FJ2"/>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="28" id="FRe-ww-FJ2"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="16"/>
<color key="textColor" name="keyChar"/>
Expand Down Expand Up @@ -87,7 +87,7 @@
<action selector="switchDidChange:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="2aX-9q-Xm3"/>
</connections>
</switch>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Z37-gs-N4L" userLabel="DescriptionLabelPhone">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Z37-gs-N4L" userLabel="DescriptionLabelPhone">
<rect key="frame" x="16" y="44" width="392" height="88"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="21" id="ynu-Q0-G95"/>
Expand Down Expand Up @@ -132,6 +132,8 @@
<constraint firstItem="iEK-aH-VJH" firstAttribute="centerY" secondItem="Y7l-w6-QQi" secondAttribute="centerY" id="pgQ-hV-7VG"/>
<constraint firstAttribute="trailing" secondItem="Z37-gs-N4L" secondAttribute="trailing" constant="16" id="v6o-1J-9JP"/>
<constraint firstAttribute="trailing" secondItem="SWG-JP-Qz7" secondAttribute="trailing" constant="16" id="vSZ-Y9-0VH"/>
<constraint firstItem="FbK-yb-cab" firstAttribute="leading" secondItem="XI7-83-3eC" secondAttribute="trailing" constant="16" id="mN7-pQ-8Kx"/>
<constraint firstItem="iEK-aH-VJH" firstAttribute="leading" secondItem="Y7l-w6-QQi" secondAttribute="trailing" constant="16" id="oP9-rS-4Lm"/>
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
Expand Down
46 changes: 40 additions & 6 deletions Scribe/Views/TableViewTemplateViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,49 @@ extension TableViewTemplateViewController {
return cell
}

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let section = tableData[indexPath.section]
let setting = section.section[indexPath.row]
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let section = dataSet[indexPath.section]
let setting = section.section[indexPath.row]

// If there's no description, return a fixed small height.
guard let description = setting.shortDescription else {
return 54.0
}

// If has description, give it more height.
let hasDescription = setting.shortDescription != nil
return hasDescription ? 100.0 : 60.0
// Calculate available width for text.
let availableWidth = tableView.bounds.width - 32

let titleFont: UIFont
let descFont: UIFont

if DeviceType.isPad {
titleFont = UIFont.systemFont(ofSize: 24, weight: .medium)
descFont = UIFont.systemFont(ofSize: 18)
} else {
titleFont = UIFont.systemFont(ofSize: 16, weight: .medium)
descFont = UIFont.systemFont(ofSize: 14)
}

// Calculate actual height needed for title text.
let titleHeight = setting.sectionTitle.boundingRect(
with: CGSize(width: availableWidth, height: .greatestFiniteMagnitude),
options: .usesLineFragmentOrigin,
attributes: [.font: titleFont],
context: nil
).height

// Calculate actual height needed for description text.
let descHeight = description.boundingRect(
with: CGSize(width: availableWidth, height: .greatestFiniteMagnitude),
options: .usesLineFragmentOrigin,
attributes: [.font: descFont],
context: nil
).height

// Return total height: title + description + padding buffer.
return ceil(titleHeight + descHeight + 52)
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let tableSection = tableData[indexPath.section]
let section = tableSection.section[indexPath.row]
Expand Down
2 changes: 1 addition & 1 deletion Scribe/i18n
Loading