Skip to content

Commit

Permalink
Add a reset badge to 0 button
Browse files Browse the repository at this point in the history
  • Loading branch information
robbiet480 committed Apr 22, 2017
1 parent 942debf commit 756e508
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 14 deletions.
15 changes: 15 additions & 0 deletions HomeAssistant/Resources/SwiftGen/Strings.swift
Expand Up @@ -375,6 +375,21 @@ enum L10n {
/// Notification Settings
static let title = L10n.tr("settings_details.notifications.title")

enum BadgeSection {

enum Button {
/// Reset badge to 0
static let title = L10n.tr("settings_details.notifications.badge_section.button.title")
}

enum ResetAlert {
/// The badge has been reset to 0.
static let message = L10n.tr("settings_details.notifications.badge_section.reset_alert.message")
/// Badge reset
static let title = L10n.tr("settings_details.notifications.badge_section.reset_alert.title")
}
}

enum PushIdSection {
/// This is the target to use in your Home Assistant configuration. Tap to copy or share.
static let footer = L10n.tr("settings_details.notifications.push_id_section.footer")
Expand Down
5 changes: 5 additions & 0 deletions HomeAssistant/Resources/en.lproj/Localizable.strings
Expand Up @@ -91,6 +91,11 @@
"settings_details.notifications.sounds_section.imported_alert.title" = "Sounds Imported";
"settings_details.notifications.sounds_section.imported_alert.message" = "%d sounds were imported. Please restart your phone to complete the import.";

"settings_details.notifications.badge_section.button.title" = "Reset badge to 0";
"settings_details.notifications.badge_section.reset_alert.title" = "Badge reset";
"settings_details.notifications.badge_section.reset_alert.message" = "The badge has been reset to 0.";



"permissions.location.message" = "We use this to inform\r\nHome Assistant of your device location and state.";
"permissions.notification.message" = "We use this to let you\r\nsend notifications to your device.";
Expand Down
41 changes: 27 additions & 14 deletions HomeAssistant/Views/SettingsDetailViewController.swift
Expand Up @@ -160,21 +160,19 @@ class SettingsDetailViewController: FormViewController {
self.present(activityViewController, animated: true, completion: {})
}

+++ Section(header: "",
// swiftlint:disable:next line_length
footer: L10n.SettingsDetails.Notifications.UpdateSection.footer)
+++ Section(header: "", footer: L10n.SettingsDetails.Notifications.UpdateSection.footer)
<<< ButtonRow {
$0.title = L10n.SettingsDetails.Notifications.UpdateSection.Button.title
}.onCellSelection {_, _ in
HomeAssistantAPI.sharedInstance.setupPush()
// swiftlint:disable:next line_length
let alert = UIAlertController(title: L10n.SettingsDetails.Notifications.UpdateSection.UpdatedAlert.title,
// swiftlint:disable:next line_length
message: L10n.SettingsDetails.Notifications.UpdateSection.UpdatedAlert.message,
preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: L10n.okLabel, style: UIAlertActionStyle.default,
handler: nil))
self.present(alert, animated: true, completion: nil)
}.onCellSelection {_, _ in
HomeAssistantAPI.sharedInstance.setupPush()
// swiftlint:disable:next line_length
let alert = UIAlertController(title: L10n.SettingsDetails.Notifications.UpdateSection.UpdatedAlert.title,
// swiftlint:disable:next line_length
message: L10n.SettingsDetails.Notifications.UpdateSection.UpdatedAlert.message,
preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: L10n.okLabel, style: UIAlertActionStyle.default,
handler: nil))
self.present(alert, animated: true, completion: nil)
}

+++ Section(header: "", footer: L10n.SettingsDetails.Notifications.SoundsSection.footer)
Expand All @@ -190,7 +188,22 @@ class SettingsDetailViewController: FormViewController {
alert.addAction(UIAlertAction(title: L10n.okLabel,
style: UIAlertActionStyle.default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
}

+++ Section(header: "", footer: "")
<<< ButtonRow {
$0.title = L10n.SettingsDetails.Notifications.BadgeSection.Button.title
}.onCellSelection {_, _ in
UIApplication.shared.applicationIconBadgeNumber = 0
// swiftlint:disable:next line_length
let alert = UIAlertController(title: L10n.SettingsDetails.Notifications.BadgeSection.ResetAlert.title,
// swiftlint:disable:next line_length
message: L10n.SettingsDetails.Notifications.BadgeSection.ResetAlert.message,
preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: L10n.okLabel,
style: UIAlertActionStyle.default, handler: nil))
self.present(alert, animated: true, completion: nil)
}

// <<< ButtonRow {
// $0.title = "Import system sounds"
Expand Down

0 comments on commit 756e508

Please sign in to comment.