diff --git a/Bark.xcodeproj/project.pbxproj b/Bark.xcodeproj/project.pbxproj index 15027c6..1e557dc 100644 --- a/Bark.xcodeproj/project.pbxproj +++ b/Bark.xcodeproj/project.pbxproj @@ -11,7 +11,40 @@ 0603706920E1F89500F4CA05 /* PreviewCardCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0603706820E1F89500F4CA05 /* PreviewCardCell.swift */; }; 0603706B20E20A7C00F4CA05 /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0603706A20E20A7C00F4CA05 /* String+Extension.swift */; }; 0603706D20E23EC000F4CA05 /* BarkSFSafariViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0603706C20E23EC000F4CA05 /* BarkSFSafariViewController.swift */; }; + 060481EE250F404500BC9799 /* SoundsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 060481ED250F404500BC9799 /* SoundsViewController.swift */; }; + 060481F0250F51CA00BC9799 /* SoundCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 060481EF250F51CA00BC9799 /* SoundCell.swift */; }; 0604F7DF20620D4900B32F09 /* ServerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0604F7DE20620D4900B32F09 /* ServerManager.swift */; }; + 0632050F250B6DD4001561EC /* gotosleep.caf in Resources */ = {isa = PBXBuildFile; fileRef = 063204F0250B6DD1001561EC /* gotosleep.caf */; }; + 06320510250B6DD4001561EC /* paymentsuccess.caf in Resources */ = {isa = PBXBuildFile; fileRef = 063204F1250B6DD1001561EC /* paymentsuccess.caf */; }; + 06320511250B6DD4001561EC /* shake.caf in Resources */ = {isa = PBXBuildFile; fileRef = 063204F2250B6DD1001561EC /* shake.caf */; }; + 06320512250B6DD4001561EC /* alarm.caf in Resources */ = {isa = PBXBuildFile; fileRef = 063204F3250B6DD1001561EC /* alarm.caf */; }; + 06320513250B6DD4001561EC /* bloom.caf in Resources */ = {isa = PBXBuildFile; fileRef = 063204F4250B6DD1001561EC /* bloom.caf */; }; + 06320514250B6DD4001561EC /* sherwoodforest.caf in Resources */ = {isa = PBXBuildFile; fileRef = 063204F5250B6DD2001561EC /* sherwoodforest.caf */; }; + 06320515250B6DD4001561EC /* healthnotification.caf in Resources */ = {isa = PBXBuildFile; fileRef = 063204F6250B6DD2001561EC /* healthnotification.caf */; }; + 06320516250B6DD4001561EC /* calypso.caf in Resources */ = {isa = PBXBuildFile; fileRef = 063204F7250B6DD2001561EC /* calypso.caf */; }; + 06320517250B6DD4001561EC /* descent.caf in Resources */ = {isa = PBXBuildFile; fileRef = 063204F8250B6DD2001561EC /* descent.caf */; }; + 06320518250B6DD4001561EC /* ladder.caf in Resources */ = {isa = PBXBuildFile; fileRef = 063204F9250B6DD2001561EC /* ladder.caf */; }; + 06320519250B6DD4001561EC /* tiptoes.caf in Resources */ = {isa = PBXBuildFile; fileRef = 063204FA250B6DD2001561EC /* tiptoes.caf */; }; + 0632051A250B6DD4001561EC /* fanfare.caf in Resources */ = {isa = PBXBuildFile; fileRef = 063204FB250B6DD2001561EC /* fanfare.caf */; }; + 0632051B250B6DD4001561EC /* birdsong.caf in Resources */ = {isa = PBXBuildFile; fileRef = 063204FC250B6DD2001561EC /* birdsong.caf */; }; + 0632051C250B6DD4001561EC /* typewriters.caf in Resources */ = {isa = PBXBuildFile; fileRef = 063204FD250B6DD2001561EC /* typewriters.caf */; }; + 0632051D250B6DD4001561EC /* anticipate.caf in Resources */ = {isa = PBXBuildFile; fileRef = 063204FE250B6DD2001561EC /* anticipate.caf */; }; + 0632051E250B6DD4001561EC /* choo.caf in Resources */ = {isa = PBXBuildFile; fileRef = 063204FF250B6DD3001561EC /* choo.caf */; }; + 0632051F250B6DD4001561EC /* glass.caf in Resources */ = {isa = PBXBuildFile; fileRef = 06320500250B6DD3001561EC /* glass.caf */; }; + 06320520250B6DD4001561EC /* telegraph.caf in Resources */ = {isa = PBXBuildFile; fileRef = 06320501250B6DD3001561EC /* telegraph.caf */; }; + 06320521250B6DD4001561EC /* multiwayinvitation.caf in Resources */ = {isa = PBXBuildFile; fileRef = 06320502250B6DD3001561EC /* multiwayinvitation.caf */; }; + 06320522250B6DD4001561EC /* newmail.caf in Resources */ = {isa = PBXBuildFile; fileRef = 06320503250B6DD3001561EC /* newmail.caf */; }; + 06320523250B6DD4001561EC /* update.caf in Resources */ = {isa = PBXBuildFile; fileRef = 06320504250B6DD3001561EC /* update.caf */; }; + 06320524250B6DD4001561EC /* minuet.caf in Resources */ = {isa = PBXBuildFile; fileRef = 06320505250B6DD3001561EC /* minuet.caf */; }; + 06320525250B6DD4001561EC /* suspense.caf in Resources */ = {isa = PBXBuildFile; fileRef = 06320506250B6DD3001561EC /* suspense.caf */; }; + 06320526250B6DD4001561EC /* mailsent.caf in Resources */ = {isa = PBXBuildFile; fileRef = 06320507250B6DD3001561EC /* mailsent.caf */; }; + 06320527250B6DD4001561EC /* noir.caf in Resources */ = {isa = PBXBuildFile; fileRef = 06320508250B6DD3001561EC /* noir.caf */; }; + 06320528250B6DD4001561EC /* chime.caf in Resources */ = {isa = PBXBuildFile; fileRef = 06320509250B6DD4001561EC /* chime.caf */; }; + 06320529250B6DD4001561EC /* spell.caf in Resources */ = {isa = PBXBuildFile; fileRef = 0632050A250B6DD4001561EC /* spell.caf */; }; + 0632052A250B6DD4001561EC /* electronic.caf in Resources */ = {isa = PBXBuildFile; fileRef = 0632050B250B6DD4001561EC /* electronic.caf */; }; + 0632052B250B6DD4001561EC /* bell.caf in Resources */ = {isa = PBXBuildFile; fileRef = 0632050C250B6DD4001561EC /* bell.caf */; }; + 0632052C250B6DD4001561EC /* horn.caf in Resources */ = {isa = PBXBuildFile; fileRef = 0632050D250B6DD4001561EC /* horn.caf */; }; + 0632052D250B6DD4001561EC /* newsflash.caf in Resources */ = {isa = PBXBuildFile; fileRef = 0632050E250B6DD4001561EC /* newsflash.caf */; }; 0632CE1F20EC9098003FDF46 /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0683487020510FB20024B6DA /* UserNotifications.framework */; }; 0632CE2020EC9098003FDF46 /* UserNotificationsUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0683487220510FB20024B6DA /* UserNotificationsUI.framework */; }; 0632CE2320EC9098003FDF46 /* NotificationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0632CE2220EC9098003FDF46 /* NotificationViewController.swift */; }; @@ -89,7 +122,40 @@ 0603706820E1F89500F4CA05 /* PreviewCardCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewCardCell.swift; sourceTree = ""; }; 0603706A20E20A7C00F4CA05 /* String+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extension.swift"; sourceTree = ""; }; 0603706C20E23EC000F4CA05 /* BarkSFSafariViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarkSFSafariViewController.swift; sourceTree = ""; }; + 060481ED250F404500BC9799 /* SoundsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoundsViewController.swift; sourceTree = ""; }; + 060481EF250F51CA00BC9799 /* SoundCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoundCell.swift; sourceTree = ""; }; 0604F7DE20620D4900B32F09 /* ServerManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerManager.swift; sourceTree = ""; }; + 063204F0250B6DD1001561EC /* gotosleep.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = gotosleep.caf; sourceTree = ""; }; + 063204F1250B6DD1001561EC /* paymentsuccess.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = paymentsuccess.caf; sourceTree = ""; }; + 063204F2250B6DD1001561EC /* shake.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = shake.caf; sourceTree = ""; }; + 063204F3250B6DD1001561EC /* alarm.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = alarm.caf; sourceTree = ""; }; + 063204F4250B6DD1001561EC /* bloom.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = bloom.caf; sourceTree = ""; }; + 063204F5250B6DD2001561EC /* sherwoodforest.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = sherwoodforest.caf; sourceTree = ""; }; + 063204F6250B6DD2001561EC /* healthnotification.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = healthnotification.caf; sourceTree = ""; }; + 063204F7250B6DD2001561EC /* calypso.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = calypso.caf; sourceTree = ""; }; + 063204F8250B6DD2001561EC /* descent.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = descent.caf; sourceTree = ""; }; + 063204F9250B6DD2001561EC /* ladder.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = ladder.caf; sourceTree = ""; }; + 063204FA250B6DD2001561EC /* tiptoes.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = tiptoes.caf; sourceTree = ""; }; + 063204FB250B6DD2001561EC /* fanfare.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = fanfare.caf; sourceTree = ""; }; + 063204FC250B6DD2001561EC /* birdsong.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = birdsong.caf; sourceTree = ""; }; + 063204FD250B6DD2001561EC /* typewriters.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = typewriters.caf; sourceTree = ""; }; + 063204FE250B6DD2001561EC /* anticipate.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = anticipate.caf; sourceTree = ""; }; + 063204FF250B6DD3001561EC /* choo.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = choo.caf; sourceTree = ""; }; + 06320500250B6DD3001561EC /* glass.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = glass.caf; sourceTree = ""; }; + 06320501250B6DD3001561EC /* telegraph.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = telegraph.caf; sourceTree = ""; }; + 06320502250B6DD3001561EC /* multiwayinvitation.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = multiwayinvitation.caf; sourceTree = ""; }; + 06320503250B6DD3001561EC /* newmail.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = newmail.caf; sourceTree = ""; }; + 06320504250B6DD3001561EC /* update.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = update.caf; sourceTree = ""; }; + 06320505250B6DD3001561EC /* minuet.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = minuet.caf; sourceTree = ""; }; + 06320506250B6DD3001561EC /* suspense.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = suspense.caf; sourceTree = ""; }; + 06320507250B6DD3001561EC /* mailsent.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = mailsent.caf; sourceTree = ""; }; + 06320508250B6DD3001561EC /* noir.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = noir.caf; sourceTree = ""; }; + 06320509250B6DD4001561EC /* chime.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = chime.caf; sourceTree = ""; }; + 0632050A250B6DD4001561EC /* spell.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = spell.caf; sourceTree = ""; }; + 0632050B250B6DD4001561EC /* electronic.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = electronic.caf; sourceTree = ""; }; + 0632050C250B6DD4001561EC /* bell.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = bell.caf; sourceTree = ""; }; + 0632050D250B6DD4001561EC /* horn.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = horn.caf; sourceTree = ""; }; + 0632050E250B6DD4001561EC /* newsflash.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = newsflash.caf; sourceTree = ""; }; 0632CE1E20EC9098003FDF46 /* NotificationContentExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = NotificationContentExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 0632CE2220EC9098003FDF46 /* NotificationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationViewController.swift; sourceTree = ""; }; 0632CE2520EC9098003FDF46 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; @@ -178,6 +244,7 @@ 0603706C20E23EC000F4CA05 /* BarkSFSafariViewController.swift */, 068F66B2247BD84C00DAD25A /* MessageListViewController.swift */, 06885EB5247FB9880004A303 /* MessageSettingsViewController.swift */, + 060481ED250F404500BC9799 /* SoundsViewController.swift */, ); path = Controller; sourceTree = ""; @@ -191,6 +258,7 @@ 06C5952E248107F5006B98F3 /* iCloudStatusCell.swift */, 06C5953024811392006B98F3 /* ArchiveSettingCell.swift */, 06C595352481160F006B98F3 /* BKLabel.swift */, + 060481EF250F51CA00BC9799 /* SoundCell.swift */, ); path = View; sourceTree = ""; @@ -214,6 +282,44 @@ path = Model; sourceTree = ""; }; + 063204EF250B6DC2001561EC /* Sounds */ = { + isa = PBXGroup; + children = ( + 063204F3250B6DD1001561EC /* alarm.caf */, + 063204FE250B6DD2001561EC /* anticipate.caf */, + 0632050C250B6DD4001561EC /* bell.caf */, + 063204FC250B6DD2001561EC /* birdsong.caf */, + 063204F4250B6DD1001561EC /* bloom.caf */, + 063204F7250B6DD2001561EC /* calypso.caf */, + 06320509250B6DD4001561EC /* chime.caf */, + 063204FF250B6DD3001561EC /* choo.caf */, + 063204F8250B6DD2001561EC /* descent.caf */, + 0632050B250B6DD4001561EC /* electronic.caf */, + 063204FB250B6DD2001561EC /* fanfare.caf */, + 06320500250B6DD3001561EC /* glass.caf */, + 063204F0250B6DD1001561EC /* gotosleep.caf */, + 063204F6250B6DD2001561EC /* healthnotification.caf */, + 0632050D250B6DD4001561EC /* horn.caf */, + 063204F9250B6DD2001561EC /* ladder.caf */, + 06320507250B6DD3001561EC /* mailsent.caf */, + 06320505250B6DD3001561EC /* minuet.caf */, + 06320502250B6DD3001561EC /* multiwayinvitation.caf */, + 06320503250B6DD3001561EC /* newmail.caf */, + 0632050E250B6DD4001561EC /* newsflash.caf */, + 06320508250B6DD3001561EC /* noir.caf */, + 063204F1250B6DD1001561EC /* paymentsuccess.caf */, + 063204F2250B6DD1001561EC /* shake.caf */, + 063204F5250B6DD2001561EC /* sherwoodforest.caf */, + 0632050A250B6DD4001561EC /* spell.caf */, + 06320506250B6DD3001561EC /* suspense.caf */, + 06320501250B6DD3001561EC /* telegraph.caf */, + 063204FA250B6DD2001561EC /* tiptoes.caf */, + 063204FD250B6DD2001561EC /* typewriters.caf */, + 06320504250B6DD3001561EC /* update.caf */, + ); + path = Sounds; + sourceTree = ""; + }; 0632CE2120EC9098003FDF46 /* NotificationContentExtension */ = { isa = PBXGroup; children = ( @@ -227,6 +333,7 @@ 0661A536204FDA4100965E4E = { isa = PBXGroup; children = ( + 063204EF250B6DC2001561EC /* Sounds */, 0604F7DD20620D3800B32F09 /* Model */, 0604F7DC20620D3400B32F09 /* View */, 0604F7DB20620D2700B32F09 /* Controller */, @@ -421,9 +528,40 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 06320525250B6DD4001561EC /* suspense.caf in Resources */, + 06320529250B6DD4001561EC /* spell.caf in Resources */, + 0632051D250B6DD4001561EC /* anticipate.caf in Resources */, + 06320521250B6DD4001561EC /* multiwayinvitation.caf in Resources */, + 06320528250B6DD4001561EC /* chime.caf in Resources */, + 06320510250B6DD4001561EC /* paymentsuccess.caf in Resources */, + 06320527250B6DD4001561EC /* noir.caf in Resources */, + 06320520250B6DD4001561EC /* telegraph.caf in Resources */, + 06320518250B6DD4001561EC /* ladder.caf in Resources */, + 06320526250B6DD4001561EC /* mailsent.caf in Resources */, + 06320523250B6DD4001561EC /* update.caf in Resources */, + 06320515250B6DD4001561EC /* healthnotification.caf in Resources */, + 06320511250B6DD4001561EC /* shake.caf in Resources */, + 06320513250B6DD4001561EC /* bloom.caf in Resources */, + 0632050F250B6DD4001561EC /* gotosleep.caf in Resources */, + 06320512250B6DD4001561EC /* alarm.caf in Resources */, + 06320522250B6DD4001561EC /* newmail.caf in Resources */, 0661A54D204FDA4100965E4E /* LaunchScreen.storyboard in Resources */, + 0632051E250B6DD4001561EC /* choo.caf in Resources */, + 06320516250B6DD4001561EC /* calypso.caf in Resources */, + 0632052D250B6DD4001561EC /* newsflash.caf in Resources */, + 06320514250B6DD4001561EC /* sherwoodforest.caf in Resources */, + 0632051A250B6DD4001561EC /* fanfare.caf in Resources */, + 06320517250B6DD4001561EC /* descent.caf in Resources */, + 0632051B250B6DD4001561EC /* birdsong.caf in Resources */, + 0632051F250B6DD4001561EC /* glass.caf in Resources */, + 06320524250B6DD4001561EC /* minuet.caf in Resources */, 063C499520E36BF9001BCA35 /* Localizable.strings in Resources */, 0661A54A204FDA4100965E4E /* Assets.xcassets in Resources */, + 06320519250B6DD4001561EC /* tiptoes.caf in Resources */, + 0632052A250B6DD4001561EC /* electronic.caf in Resources */, + 0632052C250B6DD4001561EC /* horn.caf in Resources */, + 0632051C250B6DD4001561EC /* typewriters.caf in Resources */, + 0632052B250B6DD4001561EC /* bell.caf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -516,6 +654,7 @@ files = ( 0603706920E1F89500F4CA05 /* PreviewCardCell.swift in Sources */, 0637FA8C20E0D7A700E80174 /* BaseViewController.swift in Sources */, + 060481EE250F404500BC9799 /* SoundsViewController.swift in Sources */, 0603706D20E23EC000F4CA05 /* BarkSFSafariViewController.swift in Sources */, 06C5953124811392006B98F3 /* ArchiveSettingCell.swift in Sources */, 06B1158F247BB1FB006D91FB /* Message.swift in Sources */, @@ -528,6 +667,7 @@ 0637FA8A20E0D58800E80174 /* NewServerViewController.swift in Sources */, 0637FA8220E09C4B00E80174 /* BarkNavigationController.swift in Sources */, 0637FA7A20E092B300E80174 /* Observable+Extension.swift in Sources */, + 060481F0250F51CA00BC9799 /* SoundCell.swift in Sources */, 0667D194247D1BA0005DE2ED /* Date+Extension.swift in Sources */, 0604F7DF20620D4900B32F09 /* ServerManager.swift in Sources */, 0667D192247D162C005DE2ED /* MessageTableViewCell.swift in Sources */, diff --git a/Bark/en.lproj/Localizable.strings b/Bark/en.lproj/Localizable.strings index 25c2ea3..501fb6a 100644 --- a/Bark/en.lproj/Localizable.strings +++ b/Bark/en.lproj/Localizable.strings @@ -63,3 +63,8 @@ archiveNote = "When the isArchive parameter is not specified in the push request archiveNotificationMessageTitle = "Archive notification message"; archiveNotificationMessage = "Notification message will be archived when isArchive value is 1, and will not be archived when the value is 0.\nIf the isArchive parameter is not specified, the notification message will be archived according to the default settings"; + +notificationSound = "Notification sound"; +previewSound = "Click to preview"; +setSounds = "You can set different sounds for push notifications"; +viewAllSounds = "View all sounds"; diff --git a/Bark/zh-Hans.lproj/Localizable.strings b/Bark/zh-Hans.lproj/Localizable.strings index 8120bfe..d7c2788 100644 --- a/Bark/zh-Hans.lproj/Localizable.strings +++ b/Bark/zh-Hans.lproj/Localizable.strings @@ -63,3 +63,8 @@ archiveNote = "当推送请求URL没有指定 isArchive 参数时,将按照此 archiveNotificationMessageTitle = "自动保存通知消息"; archiveNotificationMessage = "当设置 isArchive 值为 1 时,则会自动保存这条推送消息,设置为其他值时,则不会保存。\n如果不指定 isArchive 参数时,则按照默认设置保存消息,可以在 消息->设置->默认保存消息 更改默认保存设置"; + +notificationSound = "推送铃声"; +previewSound = "点击可预览"; +setSounds = "可以为推送设置不同的铃声"; +viewAllSounds = "查看所有铃声"; diff --git a/Controller/HomeViewController.swift b/Controller/HomeViewController.swift index 78298c6..cb3b514 100644 --- a/Controller/HomeViewController.swift +++ b/Controller/HomeViewController.swift @@ -37,6 +37,13 @@ class HomeViewController: BaseViewController { title: NSLocalizedString("CustomedNotificationTitle"), body: NSLocalizedString("CustomedNotificationContent"), notice: NSLocalizedString("Notice2")), + PreviewModel( + body: NSLocalizedString("notificationSound"), + notice: NSLocalizedString("setSounds"), + queryParameter: "sound=minuet", + moreInfo:NSLocalizedString("viewAllSounds"), + moreViewController: SoundsViewController() + ), PreviewModel( body: NSLocalizedString("archiveNotificationMessageTitle"), notice: NSLocalizedString("archiveNotificationMessage"), diff --git a/Controller/SoundsViewController.swift b/Controller/SoundsViewController.swift new file mode 100644 index 0000000..2922340 --- /dev/null +++ b/Controller/SoundsViewController.swift @@ -0,0 +1,64 @@ +// +// SoundsViewController.swift +// Bark +// +// Created by huangfeng on 2020/9/14. +// Copyright © 2020 Fin. All rights reserved. +// + +import UIKit +import Material +import AVKit + +class SoundsViewController: UIViewController,UITableViewDelegate,UITableViewDataSource { + let tableView: UITableView = { + let tableView = UITableView() + tableView.backgroundColor = Color.grey.lighten5 + tableView.register(UITableViewCell.self, forCellReuseIdentifier: "\(SoundCell.self)") + return tableView + }() + let audios:[AVURLAsset] = { + var urls = Bundle.main.urls(forResourcesWithExtension: "caf", subdirectory: nil) ?? [] + urls.sort { (u1, u2) -> Bool in + u1.lastPathComponent.localizedStandardCompare(u2.lastPathComponent) == ComparisonResult.orderedAscending + } + let audios = urls.map { (url) -> AVURLAsset in + let asset = AVURLAsset(url: url) + return asset + } + return audios + }() + override func viewDidLoad() { + super.viewDidLoad() + self.title = NSLocalizedString("notificationSound") + self.tableView.dataSource = self + self.tableView.delegate = self + self.view.addSubview(self.tableView) + self.tableView.snp.makeConstraints { (make) in + make.edges.equalToSuperview() + } + + let header = UILabel() + header.fontSize = 12 + header.text = " \(NSLocalizedString("previewSound"))" + header.textColor = Color.darkText.secondary + header.frame = CGRect(x: 0, y: 0, width: 0, height: 40) + self.tableView.tableHeaderView = header + } + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return audios.count + } + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "\(SoundCell.self)") as? SoundCell ?? SoundCell() + cell.nameLabel.text = audios[indexPath.row].url.deletingPathExtension().lastPathComponent + cell.durationLabel.text = "\(String(format: "%.2g", CMTimeGetSeconds(audios[indexPath.row].duration))) second(s)"; + return cell + } + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + var soundID:SystemSoundID = 0 + AudioServicesCreateSystemSoundID(audios[indexPath.row].url as CFURL, &soundID) + AudioServicesPlaySystemSoundWithCompletion(soundID) { + AudioServicesDisposeSystemSoundID(soundID) + } + } +} diff --git a/Sounds/alarm.caf b/Sounds/alarm.caf new file mode 100644 index 0000000..03ef9bb Binary files /dev/null and b/Sounds/alarm.caf differ diff --git a/Sounds/anticipate.caf b/Sounds/anticipate.caf new file mode 100644 index 0000000..06dbb89 Binary files /dev/null and b/Sounds/anticipate.caf differ diff --git a/Sounds/bell.caf b/Sounds/bell.caf new file mode 100644 index 0000000..e866d00 Binary files /dev/null and b/Sounds/bell.caf differ diff --git a/Sounds/birdsong.caf b/Sounds/birdsong.caf new file mode 100644 index 0000000..c25c114 Binary files /dev/null and b/Sounds/birdsong.caf differ diff --git a/Sounds/bloom.caf b/Sounds/bloom.caf new file mode 100644 index 0000000..42642de Binary files /dev/null and b/Sounds/bloom.caf differ diff --git a/Sounds/calypso.caf b/Sounds/calypso.caf new file mode 100644 index 0000000..0d7f2f7 Binary files /dev/null and b/Sounds/calypso.caf differ diff --git a/Sounds/chime.caf b/Sounds/chime.caf new file mode 100644 index 0000000..7ac2139 Binary files /dev/null and b/Sounds/chime.caf differ diff --git a/Sounds/choo.caf b/Sounds/choo.caf new file mode 100644 index 0000000..4ed0a2c Binary files /dev/null and b/Sounds/choo.caf differ diff --git a/Sounds/descent.caf b/Sounds/descent.caf new file mode 100644 index 0000000..3f9a5ec Binary files /dev/null and b/Sounds/descent.caf differ diff --git a/Sounds/electronic.caf b/Sounds/electronic.caf new file mode 100644 index 0000000..1a1297f Binary files /dev/null and b/Sounds/electronic.caf differ diff --git a/Sounds/fanfare.caf b/Sounds/fanfare.caf new file mode 100644 index 0000000..ae9ca7c Binary files /dev/null and b/Sounds/fanfare.caf differ diff --git a/Sounds/glass.caf b/Sounds/glass.caf new file mode 100644 index 0000000..d7f2673 Binary files /dev/null and b/Sounds/glass.caf differ diff --git a/Sounds/gotosleep.caf b/Sounds/gotosleep.caf new file mode 100644 index 0000000..70ae743 Binary files /dev/null and b/Sounds/gotosleep.caf differ diff --git a/Sounds/healthnotification.caf b/Sounds/healthnotification.caf new file mode 100644 index 0000000..be54bc3 Binary files /dev/null and b/Sounds/healthnotification.caf differ diff --git a/Sounds/horn.caf b/Sounds/horn.caf new file mode 100644 index 0000000..c9f325b Binary files /dev/null and b/Sounds/horn.caf differ diff --git a/Sounds/ladder.caf b/Sounds/ladder.caf new file mode 100644 index 0000000..bac1772 Binary files /dev/null and b/Sounds/ladder.caf differ diff --git a/Sounds/mailsent.caf b/Sounds/mailsent.caf new file mode 100644 index 0000000..fc1c8ca Binary files /dev/null and b/Sounds/mailsent.caf differ diff --git a/Sounds/minuet.caf b/Sounds/minuet.caf new file mode 100644 index 0000000..39c1199 Binary files /dev/null and b/Sounds/minuet.caf differ diff --git a/Sounds/multiwayinvitation.caf b/Sounds/multiwayinvitation.caf new file mode 100644 index 0000000..35b8a58 Binary files /dev/null and b/Sounds/multiwayinvitation.caf differ diff --git a/Sounds/newmail.caf b/Sounds/newmail.caf new file mode 100644 index 0000000..228f2fb Binary files /dev/null and b/Sounds/newmail.caf differ diff --git a/Sounds/newsflash.caf b/Sounds/newsflash.caf new file mode 100644 index 0000000..34d55af Binary files /dev/null and b/Sounds/newsflash.caf differ diff --git a/Sounds/noir.caf b/Sounds/noir.caf new file mode 100644 index 0000000..12997da Binary files /dev/null and b/Sounds/noir.caf differ diff --git a/Sounds/paymentsuccess.caf b/Sounds/paymentsuccess.caf new file mode 100644 index 0000000..e711f0a Binary files /dev/null and b/Sounds/paymentsuccess.caf differ diff --git a/Sounds/shake.caf b/Sounds/shake.caf new file mode 100644 index 0000000..17fe6bd Binary files /dev/null and b/Sounds/shake.caf differ diff --git a/Sounds/sherwoodforest.caf b/Sounds/sherwoodforest.caf new file mode 100644 index 0000000..5132f49 Binary files /dev/null and b/Sounds/sherwoodforest.caf differ diff --git a/Sounds/spell.caf b/Sounds/spell.caf new file mode 100644 index 0000000..364fe50 Binary files /dev/null and b/Sounds/spell.caf differ diff --git a/Sounds/suspense.caf b/Sounds/suspense.caf new file mode 100644 index 0000000..64fef8f Binary files /dev/null and b/Sounds/suspense.caf differ diff --git a/Sounds/telegraph.caf b/Sounds/telegraph.caf new file mode 100644 index 0000000..a5b210d Binary files /dev/null and b/Sounds/telegraph.caf differ diff --git a/Sounds/tiptoes.caf b/Sounds/tiptoes.caf new file mode 100644 index 0000000..a9d2793 Binary files /dev/null and b/Sounds/tiptoes.caf differ diff --git a/Sounds/typewriters.caf b/Sounds/typewriters.caf new file mode 100644 index 0000000..6dca18b Binary files /dev/null and b/Sounds/typewriters.caf differ diff --git a/Sounds/update.caf b/Sounds/update.caf new file mode 100644 index 0000000..5f4b4e5 Binary files /dev/null and b/Sounds/update.caf differ diff --git a/View/PreviewCardCell.swift b/View/PreviewCardCell.swift index 287d7b8..ba20e92 100644 --- a/View/PreviewCardCell.swift +++ b/View/PreviewCardCell.swift @@ -16,14 +16,26 @@ class PreviewModel: NSObject { var notice:String? var queryParameter:String? var image:UIImage? + var moreInfo:String? + var moreViewController:UIViewController? - init(title:String? = nil, body:String? = nil, category:String? = nil, notice:String? = nil, queryParameter:String? = nil, image:UIImage? = nil) { + init(title:String? = nil, + body:String? = nil, + category:String? = nil, + notice:String? = nil, + queryParameter:String? = nil, + image:UIImage? = nil, + moreInfo:String? = nil, + moreViewController:UIViewController? = nil + ) { self.title = title self.body = body self.category = category self.notice = notice self.queryParameter = queryParameter self.image = image + self.moreInfo = moreInfo + self.moreViewController = moreViewController } } @@ -126,9 +138,14 @@ class PreviewCardCell: UITableViewCell { previewButton.addTarget(self, action: #selector(preview), for: .touchUpInside) copyButton.addTarget(self, action: #selector(copyURL), for: .touchUpInside) + noticeLabel.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(noticeTap))) } - + @objc func noticeTap(){ + if let controller = self.previewModel?.moreViewController{ + Client.shared.currentNavigationController?.pushViewController(controller, animated: true) + } + } @objc func copyURL(){ if let urlStr = self.contentLabel.text{ UIPasteboard.general.string = urlStr @@ -203,8 +220,27 @@ class PreviewCardCell: UITableViewCell { ])) } self.contentLabel.attributedText = attrStr - self.noticeLabel.text = model.notice + if let moreInfo = model.moreInfo { + let noticeStr = "\(model.notice ?? "") \(moreInfo)" + let noticeAttrStr = NSMutableAttributedString(string: noticeStr, attributes: [ + NSAttributedString.Key.foregroundColor: Color.grey.base, + NSAttributedString.Key.font : RobotoFont.regular(with: 12) + ]) + noticeAttrStr.setAttributes([ + NSAttributedString.Key.foregroundColor: Color.blue.base, + NSAttributedString.Key.font : RobotoFont.regular(with: 12) + ], range: NSRange(location: noticeStr.count - moreInfo.count, length: moreInfo.count)) + self.noticeLabel.text = nil + self.noticeLabel.attributedText = noticeAttrStr + self.noticeLabel.isUserInteractionEnabled = true + } + else{ + self.noticeLabel.isUserInteractionEnabled = false + self.noticeLabel.attributedText = nil + self.noticeLabel.text = model.notice + } + if let image = model.image { self.contentImageView.image = image let width = UIScreen.main.bounds.size.width - 20 diff --git a/View/SoundCell.swift b/View/SoundCell.swift new file mode 100644 index 0000000..7ae9e04 --- /dev/null +++ b/View/SoundCell.swift @@ -0,0 +1,57 @@ +// +// SoundCell.swift +// Bark +// +// Created by huangfeng on 2020/9/14. +// Copyright © 2020 Fin. All rights reserved. +// + +import UIKit +import Material + +class SoundCell: UITableViewCell { + let copyButton = IconButton(image: UIImage(named: "baseline_file_copy_white_24pt"), tintColor: Color.grey.base) + let nameLabel:UILabel = { + let label = UILabel() + label.fontSize = 14 + label.textColor = Color.darkText.primary + return label + }() + let durationLabel:UILabel = { + let label = UILabel() + label.fontSize = 12 + label.textColor = Color.darkText.secondary + return label + }() + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + self.selectionStyle = .none + + self.contentView.addSubview(nameLabel) + self.contentView.addSubview(durationLabel) + nameLabel.snp.makeConstraints { (make) in + make.left.top.equalToSuperview().offset(15) + } + durationLabel.snp.makeConstraints { (make) in + make.left.equalTo(nameLabel) + make.top.equalTo(nameLabel.snp.bottom).offset(5) + make.bottom.equalToSuperview().offset(-15) + } + self.contentView.addSubview(copyButton) + copyButton.snp.makeConstraints { (make) in + make.right.equalToSuperview().offset(-15) + make.centerY.equalToSuperview() + make.width.height.equalTo(40) + } + copyButton.addTarget(self, action: #selector(copyName), for: .touchUpInside) + } + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + @objc func copyName(){ + if let urlStr = self.nameLabel.text{ + UIPasteboard.general.string = urlStr + Client.shared.currentNavigationController?.showSnackbar(text: NSLocalizedString("Copy")) + } + } +}