设置推送铃声

This commit is contained in:
Fin 2020-09-14 16:04:43 +08:00
parent b390f25640
commit 30ca5b32c1
38 changed files with 317 additions and 3 deletions

View File

@ -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 = "<group>"; };
0603706A20E20A7C00F4CA05 /* String+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extension.swift"; sourceTree = "<group>"; };
0603706C20E23EC000F4CA05 /* BarkSFSafariViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarkSFSafariViewController.swift; sourceTree = "<group>"; };
060481ED250F404500BC9799 /* SoundsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoundsViewController.swift; sourceTree = "<group>"; };
060481EF250F51CA00BC9799 /* SoundCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoundCell.swift; sourceTree = "<group>"; };
0604F7DE20620D4900B32F09 /* ServerManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerManager.swift; sourceTree = "<group>"; };
063204F0250B6DD1001561EC /* gotosleep.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = gotosleep.caf; sourceTree = "<group>"; };
063204F1250B6DD1001561EC /* paymentsuccess.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = paymentsuccess.caf; sourceTree = "<group>"; };
063204F2250B6DD1001561EC /* shake.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = shake.caf; sourceTree = "<group>"; };
063204F3250B6DD1001561EC /* alarm.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = alarm.caf; sourceTree = "<group>"; };
063204F4250B6DD1001561EC /* bloom.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = bloom.caf; sourceTree = "<group>"; };
063204F5250B6DD2001561EC /* sherwoodforest.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = sherwoodforest.caf; sourceTree = "<group>"; };
063204F6250B6DD2001561EC /* healthnotification.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = healthnotification.caf; sourceTree = "<group>"; };
063204F7250B6DD2001561EC /* calypso.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = calypso.caf; sourceTree = "<group>"; };
063204F8250B6DD2001561EC /* descent.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = descent.caf; sourceTree = "<group>"; };
063204F9250B6DD2001561EC /* ladder.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = ladder.caf; sourceTree = "<group>"; };
063204FA250B6DD2001561EC /* tiptoes.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = tiptoes.caf; sourceTree = "<group>"; };
063204FB250B6DD2001561EC /* fanfare.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = fanfare.caf; sourceTree = "<group>"; };
063204FC250B6DD2001561EC /* birdsong.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = birdsong.caf; sourceTree = "<group>"; };
063204FD250B6DD2001561EC /* typewriters.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = typewriters.caf; sourceTree = "<group>"; };
063204FE250B6DD2001561EC /* anticipate.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = anticipate.caf; sourceTree = "<group>"; };
063204FF250B6DD3001561EC /* choo.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = choo.caf; sourceTree = "<group>"; };
06320500250B6DD3001561EC /* glass.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = glass.caf; sourceTree = "<group>"; };
06320501250B6DD3001561EC /* telegraph.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = telegraph.caf; sourceTree = "<group>"; };
06320502250B6DD3001561EC /* multiwayinvitation.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = multiwayinvitation.caf; sourceTree = "<group>"; };
06320503250B6DD3001561EC /* newmail.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = newmail.caf; sourceTree = "<group>"; };
06320504250B6DD3001561EC /* update.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = update.caf; sourceTree = "<group>"; };
06320505250B6DD3001561EC /* minuet.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = minuet.caf; sourceTree = "<group>"; };
06320506250B6DD3001561EC /* suspense.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = suspense.caf; sourceTree = "<group>"; };
06320507250B6DD3001561EC /* mailsent.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = mailsent.caf; sourceTree = "<group>"; };
06320508250B6DD3001561EC /* noir.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = noir.caf; sourceTree = "<group>"; };
06320509250B6DD4001561EC /* chime.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = chime.caf; sourceTree = "<group>"; };
0632050A250B6DD4001561EC /* spell.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = spell.caf; sourceTree = "<group>"; };
0632050B250B6DD4001561EC /* electronic.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = electronic.caf; sourceTree = "<group>"; };
0632050C250B6DD4001561EC /* bell.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = bell.caf; sourceTree = "<group>"; };
0632050D250B6DD4001561EC /* horn.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = horn.caf; sourceTree = "<group>"; };
0632050E250B6DD4001561EC /* newsflash.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = newsflash.caf; sourceTree = "<group>"; };
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 = "<group>"; };
0632CE2520EC9098003FDF46 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
@ -178,6 +244,7 @@
0603706C20E23EC000F4CA05 /* BarkSFSafariViewController.swift */,
068F66B2247BD84C00DAD25A /* MessageListViewController.swift */,
06885EB5247FB9880004A303 /* MessageSettingsViewController.swift */,
060481ED250F404500BC9799 /* SoundsViewController.swift */,
);
path = Controller;
sourceTree = "<group>";
@ -191,6 +258,7 @@
06C5952E248107F5006B98F3 /* iCloudStatusCell.swift */,
06C5953024811392006B98F3 /* ArchiveSettingCell.swift */,
06C595352481160F006B98F3 /* BKLabel.swift */,
060481EF250F51CA00BC9799 /* SoundCell.swift */,
);
path = View;
sourceTree = "<group>";
@ -214,6 +282,44 @@
path = Model;
sourceTree = "<group>";
};
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 = "<group>";
};
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 */,

View File

@ -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";

View File

@ -63,3 +63,8 @@ archiveNote = "当推送请求URL没有指定 isArchive 参数时,将按照此
archiveNotificationMessageTitle = "自动保存通知消息";
archiveNotificationMessage = "当设置 isArchive 值为 1 时,则会自动保存这条推送消息,设置为其他值时,则不会保存。\n如果不指定 isArchive 参数时,则按照默认设置保存消息,可以在 消息->设置->默认保存消息 更改默认保存设置";
notificationSound = "推送铃声";
previewSound = "点击可预览";
setSounds = "可以为推送设置不同的铃声";
viewAllSounds = "查看所有铃声";

View File

@ -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"),

View File

@ -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)
}
}
}

BIN
Sounds/alarm.caf Normal file

Binary file not shown.

BIN
Sounds/anticipate.caf Normal file

Binary file not shown.

BIN
Sounds/bell.caf Normal file

Binary file not shown.

BIN
Sounds/birdsong.caf Normal file

Binary file not shown.

BIN
Sounds/bloom.caf Normal file

Binary file not shown.

BIN
Sounds/calypso.caf Normal file

Binary file not shown.

BIN
Sounds/chime.caf Normal file

Binary file not shown.

BIN
Sounds/choo.caf Normal file

Binary file not shown.

BIN
Sounds/descent.caf Normal file

Binary file not shown.

BIN
Sounds/electronic.caf Normal file

Binary file not shown.

BIN
Sounds/fanfare.caf Normal file

Binary file not shown.

BIN
Sounds/glass.caf Normal file

Binary file not shown.

BIN
Sounds/gotosleep.caf Normal file

Binary file not shown.

Binary file not shown.

BIN
Sounds/horn.caf Normal file

Binary file not shown.

BIN
Sounds/ladder.caf Normal file

Binary file not shown.

BIN
Sounds/mailsent.caf Normal file

Binary file not shown.

BIN
Sounds/minuet.caf Normal file

Binary file not shown.

Binary file not shown.

BIN
Sounds/newmail.caf Normal file

Binary file not shown.

BIN
Sounds/newsflash.caf Normal file

Binary file not shown.

BIN
Sounds/noir.caf Normal file

Binary file not shown.

BIN
Sounds/paymentsuccess.caf Normal file

Binary file not shown.

BIN
Sounds/shake.caf Normal file

Binary file not shown.

BIN
Sounds/sherwoodforest.caf Normal file

Binary file not shown.

BIN
Sounds/spell.caf Normal file

Binary file not shown.

BIN
Sounds/suspense.caf Normal file

Binary file not shown.

BIN
Sounds/telegraph.caf Normal file

Binary file not shown.

BIN
Sounds/tiptoes.caf Normal file

Binary file not shown.

BIN
Sounds/typewriters.caf Normal file

Binary file not shown.

BIN
Sounds/update.caf Normal file

Binary file not shown.

View File

@ -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

57
View/SoundCell.swift Normal file
View File

@ -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"))
}
}
}