Skip to content
This repository has been archived by the owner on Feb 27, 2019. It is now read-only.

Allow more characters and remove the need for hard-coded line breaks in labels #164

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions PermissionScope-example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class ViewController: UIViewController {
// Do any additional setup after loading the view, typically from a nib.

singlePscope.addPermission(NotificationsPermission(notificationCategories: nil),
message: "We use this to send you\r\nspam and love notes")
message: "We use this to send you spam and love notes")

multiPscope.addPermission(ContactsPermission(),
message: "We use this to steal\r\nyour friends")
message: "We use this to steal your friends")
multiPscope.addPermission(NotificationsPermission(notificationCategories: nil),
message: "We use this to send you\r\nspam and love notes")
message: "We use this to send you spam and love notes")
multiPscope.addPermission(LocationWhileInUsePermission(),
message: "We use this to track\r\nwhere you live")
message: "We use this to track where you live")

// Other example permissions
// multiPscope.addPermission(MicrophonePermission(),message: "We can hear you")
Expand Down
12 changes: 8 additions & 4 deletions PermissionScope/PermissionScope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ typealias resultsForConfigClosure = ([PermissionResult]) -> Void

/// Header UILabel with the message "Hey, listen!" by default.
public var headerLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 50))
/// Header UILabel with the message "We need a couple things\r\nbefore you get started." by default.
/// Header UILabel with the message "We need a couple things before you get started." by default.
public var bodyLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 240, height: 70))
/// Color for the close button's text color.
public var closeButtonTextColor = UIColor(red: 0, green: 0.47, blue: 1, alpha: 1)
Expand Down Expand Up @@ -186,8 +186,8 @@ typealias resultsForConfigClosure = ([PermissionResult]) -> Void
bodyLabel.font = UIFont.boldSystemFontOfSize(16)
bodyLabel.textColor = UIColor.blackColor()
bodyLabel.textAlignment = NSTextAlignment.Center
bodyLabel.text = "We need a couple things\r\nbefore you get started.".localized
bodyLabel.numberOfLines = 2
bodyLabel.text = "We need a couple things, before you get started.".localized
bodyLabel.numberOfLines = 0

contentView.addSubview(bodyLabel)

Expand Down Expand Up @@ -245,6 +245,8 @@ typealias resultsForConfigClosure = ([PermissionResult]) -> Void
bodyLabel.center = contentView.center
bodyLabel.frame.offsetInPlace(dx: -contentView.frame.origin.x, dy: -contentView.frame.origin.y)
bodyLabel.frame.offsetInPlace(dx: 0, dy: -((dialogHeight/2)-100))
bodyLabel.adjustsFontSizeToFitWidth = true
bodyLabel.minimumScaleFactor = 0.75

closeButton.center = contentView.center
closeButton.frame.offsetInPlace(dx: -contentView.frame.origin.x, dy: -contentView.frame.origin.y)
Expand Down Expand Up @@ -372,7 +374,9 @@ typealias resultsForConfigClosure = ([PermissionResult]) -> Void
func permissionStyledLabel(type: PermissionType) -> UILabel {
let label = UILabel(frame: CGRect(x: 0, y: 0, width: 260, height: 50))
label.font = labelFont
label.numberOfLines = 2
label.numberOfLines = 0
label.adjustsFontSizeToFitWidth = true
label.minimumScaleFactor = 0.75
label.textAlignment = .Center
label.text = permissionMessages[type]
label.textColor = permissionLabelColor
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ class ViewController: UIViewController {

// Set up permissions
pscope.addPermission(ContactsPermission(),
message: "We use this to steal\r\nyour friends")
message: "We use this to steal your friends")
pscope.addPermission(NotificationsPermission(notificationCategories: nil),
message: "We use this to send you\r\nspam and love notes")
message: "We use this to send you spam and love notes")
pscope.addPermission(LocationWhileInUsePermission(),
message: "We use this to track\r\nwhere you live")
message: "We use this to track where you live")

// Show dialog with callbacks
pscope.show({ finished, results in
Expand All @@ -93,7 +93,7 @@ You can easily change the colors, label and buttons fonts with PermissionScope b
Field | Type | Comment
----- | ---- | -------
headerLabel | UILabel | Header UILabel with the message "Hey, listen!" by default.
bodyLabel | UILabel | Header UILabel with the message "We need a couple things\r\nbefore you get started." by default.
bodyLabel | UILabel | Header UILabel with the message "We need a couple things before you get started." by default.
closeButtonTextColor | UIColor | Color for the close button's text color.
permissionButtonTextColor | UIColor | Color for the permission buttons' text color.
permissionButtonBorderColor | UIColor | Color for the permission buttons' border color.
Expand Down
2 changes: 1 addition & 1 deletion files/English.strings
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
//
"Close" = "";
"Hey, listen!" = "";
"We need a couple things\r\nbefore you get started." = "";
"We need a couple things before you get started." = "";
"Permission for Contacts was denied." = "";
"Permission for Events was denied." = "";
"Permission for Location was denied." = "";
Expand Down
2 changes: 1 addition & 1 deletion files/German.strings
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
//
"Close" = "Aus";
"Hey, listen!" = "Hey, du!";
"We need a couple things\r\nbefore you get started." = "Wir brauchen noch etwas,\r\n bevor du starten kannst!";
"We need a couple things before you get started." = "Wir brauchen noch etwas, bevor du starten kannst!";
"Permission for Contacts was denied." = "Genehmigung für Kontakte wurde abgelehnt.";
"Permission for Events was denied." = "Erlaubnis für Kalender wurde abgelehnt.";
"Permission for Location was denied." = "Genehmigung für Standort verweigert wurde.";
Expand Down
10 changes: 5 additions & 5 deletions objc-example/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ - (void)viewDidLoad {
self.singlePscope = [[PermissionScope alloc]init];
self.multiPscope = [[PermissionScope alloc]init];

[self.singlePscope addPermission:[[NotificationsPermission alloc]initWithNotificationCategories:nil] message:@"We use this to send you\r\nspam and love notes"];
[self.singlePscope addPermission:[[NotificationsPermission alloc]initWithNotificationCategories:nil] message:@"We use this to send you spam and love notes"];

[self.multiPscope addPermission:[[ContactsPermission alloc]init] message:@"We use this to steal\r\nyour friends"];
[self.multiPscope addPermission:[[NotificationsPermission alloc]initWithNotificationCategories:nil] message:@"We use this to send you\r\nspam and love notes"];
[self.multiPscope addPermission:[[LocationWhileInUsePermission alloc]init] message:@"We use this to track\r\nwhere you live"];
[self.multiPscope addPermission:[[ContactsPermission alloc]init] message:@"We use this to steal your friends"];
[self.multiPscope addPermission:[[NotificationsPermission alloc]initWithNotificationCategories:nil] message:@"We use this to send you spam and love notes"];
[self.multiPscope addPermission:[[LocationWhileInUsePermission alloc]init] message:@"We use this to track where you live"];
// [self.multiPscope addPermission:[[BluetoothPermission alloc]init] message:@"We use this to drain your battery"];
// [self.multiPscope addPermission:[[MotionPermission alloc]init] message:@"We use this to detect if you are\r\nThe Flash"];
// [self.multiPscope addPermission:[[MotionPermission alloc]init] message:@"We use this to detect if you are The Flash"];
}

- (IBAction)single {
Expand Down