Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Button to display Push Notification info in Settings #2282

Merged
merged 2 commits into from
Oct 13, 2018
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
53 changes: 53 additions & 0 deletions Classes/Settings/PushNotificationsDisclaimerViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// PushNotificationsDisclaimerViewController.swift
// Freetime
//
// Created by Ryan Nystrom on 10/13/18.
// Copyright © 2018 Ryan Nystrom. All rights reserved.
//

import UIKit

final class PushNotificationsDisclaimerViewController: UIViewController {

private let textView = UITextView()

override func viewDidLoad() {
super.viewDidLoad()

navigationItem.rightBarButtonItem = UIBarButtonItem(
barButtonSystemItem: .done,
target: self,
action: #selector(onDone)
)
title = NSLocalizedString("Push Notifications", comment: "")

textView.textContainerInset = UIEdgeInsets(
top: 0,
left: Styles.Sizes.gutter,
bottom: Styles.Sizes.gutter,
right: Styles.Sizes.gutter
)
textView.isEditable = false

textView.font = Styles.Text.body.preferredFont
textView.textColor = Styles.Colors.Gray.dark.color
textView.text = NSLocalizedString("GitHawk uses iOS background fetch to periodically check for new GitHub notifications. When there is new content available, GitHawk sends alerts with local notifications.\n\nThis setup requires Background App Refresh be enabled to work. Enable this feature in Settings > General > Background App Refresh.\n\nAt GitHawk, we value your privacy and data. Real-time push notifications require sending your authentication data to servers, which is a security risk we want to avoid.", comment: "")
Copy link
Collaborator

@BasThomas BasThomas Oct 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe put this in a multiline string?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that work for localized strings?

Copy link
Collaborator

@BasThomas BasThomas Oct 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like it is possible, but it looks more of a hassle than when we don't: https://stackoverflow.com/a/51478852.

view.addSubview(textView)

preferredContentSize = textView.sizeThatFits(CGSize(
width: min(320, UIScreen.main.bounds.width - Styles.Sizes.rowSpacing * 2),
height: CGFloat.greatestFiniteMagnitude
))
}

override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
textView.frame = view.bounds
}

@objc private func onDone() {
dismiss(animated: true)
}

}
9 changes: 9 additions & 0 deletions Classes/Settings/Settings.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,21 @@
<action selector="onSettings:" destination="NnB-TU-bkW" eventType="touchUpInside" id="eCr-BP-8PS"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="infoLight" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="viN-2G-VUO">
<rect key="frame" x="156" y="11" width="22" height="22"/>
<color key="tintColor" red="0.63921568627450975" green="0.66666666666666663" blue="0.69411764705882351" alpha="1" colorSpace="calibratedRGB"/>
<connections>
<action selector="onPushNotificationsInfo:" destination="NnB-TU-bkW" eventType="touchUpInside" id="PrO-Nb-3b4"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="T30-uT-48L" secondAttribute="trailing" constant="15" id="6RB-2m-fYA"/>
<constraint firstItem="HFk-Cc-92g" firstAttribute="centerY" secondItem="nUN-Hd-0xp" secondAttribute="centerY" id="Ind-0b-it6"/>
<constraint firstItem="viN-2G-VUO" firstAttribute="leading" secondItem="vNL-qr-bAj" secondAttribute="trailing" constant="8" id="JaP-4a-w1r"/>
<constraint firstItem="vNL-qr-bAj" firstAttribute="centerY" secondItem="nUN-Hd-0xp" secondAttribute="centerY" id="TTt-u4-ANE"/>
<constraint firstAttribute="trailing" secondItem="HFk-Cc-92g" secondAttribute="trailing" id="ZLK-Ic-qgC"/>
<constraint firstItem="viN-2G-VUO" firstAttribute="centerY" secondItem="nUN-Hd-0xp" secondAttribute="centerY" id="dAd-9o-KqZ"/>
<constraint firstItem="vNL-qr-bAj" firstAttribute="leading" secondItem="nUN-Hd-0xp" secondAttribute="leading" constant="16" id="o6O-Rl-PO6"/>
<constraint firstItem="T30-uT-48L" firstAttribute="centerY" secondItem="nUN-Hd-0xp" secondAttribute="centerY" id="wgd-mx-RqK"/>
</constraints>
Expand Down
4 changes: 4 additions & 0 deletions Classes/Settings/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ NewIssueTableViewControllerDelegate {
@IBAction func onSignature(_ sender: Any) {
Signature.enabled = signatureSwitch.isOn
}

@IBAction func onPushNotificationsInfo(_ sender: Any) {
showContextualMenu(PushNotificationsDisclaimerViewController())
}

// MARK: NewIssueTableViewControllerDelegate

Expand Down
4 changes: 4 additions & 0 deletions Freetime.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
292ACE1B1F5CAFAD00C9A02C /* RepositoryEmptyResultsType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 292ACE1A1F5CAFAD00C9A02C /* RepositoryEmptyResultsType.swift */; };
292ACE1E1F5CB02400C9A02C /* RepositoryEmptyResultsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 292ACE1C1F5CB02400C9A02C /* RepositoryEmptyResultsCell.swift */; };
292ACE1F1F5CB02400C9A02C /* RepositoryEmptyResultsSectionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 292ACE1D1F5CB02400C9A02C /* RepositoryEmptyResultsSectionController.swift */; };
292AD6B2217236C200273D80 /* PushNotificationsDisclaimerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 292AD6B1217236C200273D80 /* PushNotificationsDisclaimerViewController.swift */; };
292CD3BB1F0AF28F00D3D57B /* IssueDiffHunkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 292CD3BA1F0AF28F00D3D57B /* IssueDiffHunkModel.swift */; };
292CD3BD1F0AF3B800D3D57B /* IssueDiffHunkSectionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 292CD3BC1F0AF3B800D3D57B /* IssueDiffHunkSectionController.swift */; };
292CD3BF1F0AF3C000D3D57B /* IssueDiffHunkPathCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 292CD3BE1F0AF3C000D3D57B /* IssueDiffHunkPathCell.swift */; };
Expand Down Expand Up @@ -603,6 +604,7 @@
292ACE1A1F5CAFAD00C9A02C /* RepositoryEmptyResultsType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepositoryEmptyResultsType.swift; sourceTree = "<group>"; };
292ACE1C1F5CB02400C9A02C /* RepositoryEmptyResultsCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepositoryEmptyResultsCell.swift; sourceTree = "<group>"; };
292ACE1D1F5CB02400C9A02C /* RepositoryEmptyResultsSectionController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepositoryEmptyResultsSectionController.swift; sourceTree = "<group>"; };
292AD6B1217236C200273D80 /* PushNotificationsDisclaimerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PushNotificationsDisclaimerViewController.swift; sourceTree = "<group>"; };
292CD3BA1F0AF28F00D3D57B /* IssueDiffHunkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssueDiffHunkModel.swift; sourceTree = "<group>"; };
292CD3BC1F0AF3B800D3D57B /* IssueDiffHunkSectionController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssueDiffHunkSectionController.swift; sourceTree = "<group>"; };
292CD3BE1F0AF3C000D3D57B /* IssueDiffHunkPathCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssueDiffHunkPathCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1902,6 +1904,7 @@
isa = PBXGroup;
children = (
2930988E211F32D100E1178B /* DefaultReactionDetailController.swift */,
292AD6B1217236C200273D80 /* PushNotificationsDisclaimerViewController.swift */,
292FF8AB1F2FD3EC009E63F7 /* Settings.storyboard */,
297FB7771F51128A00F2E618 /* SettingsAccountsViewController.swift */,
29764C131FDC4DB60095FF95 /* SettingsLabel.swift */,
Expand Down Expand Up @@ -3023,6 +3026,7 @@
29DAA7AF20202BEA0029277A /* PullRequestReviewReplyModel.swift in Sources */,
29B94E691FCB36A000715D7E /* File+ListDiffable.swift in Sources */,
986B873E1F2E1CE400AAB55C /* RepositoryClient.swift in Sources */,
292AD6B2217236C200273D80 /* PushNotificationsDisclaimerViewController.swift in Sources */,
295A77BE1F75C1CC007BC403 /* RepositoryDetails.swift in Sources */,
292ACE1E1F5CB02400C9A02C /* RepositoryEmptyResultsCell.swift in Sources */,
292ACE1F1F5CB02400C9A02C /* RepositoryEmptyResultsSectionController.swift in Sources */,
Expand Down