Skip to content

Commit 24dbcba

Browse files
committed
swift-format
1 parent f685b3c commit 24dbcba

13 files changed

Lines changed: 935 additions & 835 deletions

ios/.swift-format

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"fileScopedDeclarationPrivacy" : {
3+
"accessLevel" : "private"
4+
},
5+
"indentConditionalCompilationBlocks" : true,
6+
"indentSwitchCaseLabels" : false,
7+
"indentation" : {
8+
"spaces" : 2
9+
},
10+
"lineBreakAroundMultilineExpressionChainComponents" : false,
11+
"lineBreakBeforeControlFlowKeywords" : false,
12+
"lineBreakBeforeEachArgument" : false,
13+
"lineBreakBeforeEachGenericRequirement" : false,
14+
"lineBreakBetweenDeclarationAttributes" : false,
15+
"lineLength" : 120,
16+
"maximumBlankLines" : 1,
17+
"multiElementCollectionTrailingCommas" : true,
18+
"noAssignmentInExpressions" : {
19+
"allowedFunctions" : [
20+
"XCTAssertNoThrow"
21+
]
22+
},
23+
"prioritizeKeepingFunctionOutputTogether" : false,
24+
"reflowMultilineStringLiterals" : "never",
25+
"respectsExistingLineBreaks" : true,
26+
"rules" : {
27+
"AllPublicDeclarationsHaveDocumentation" : false,
28+
"AlwaysUseLiteralForEmptyCollectionInit" : false,
29+
"AlwaysUseLowerCamelCase" : true,
30+
"AmbiguousTrailingClosureOverload" : true,
31+
"AvoidRetroactiveConformances" : true,
32+
"BeginDocumentationCommentWithOneLineSummary" : false,
33+
"DoNotUseSemicolons" : true,
34+
"DontRepeatTypeInStaticProperties" : true,
35+
"FileScopedDeclarationPrivacy" : true,
36+
"FullyIndirectEnum" : true,
37+
"GroupNumericLiterals" : true,
38+
"IdentifiersMustBeASCII" : true,
39+
"NeverForceUnwrap" : false,
40+
"NeverUseForceTry" : false,
41+
"NeverUseImplicitlyUnwrappedOptionals" : false,
42+
"NoAccessLevelOnExtensionDeclaration" : true,
43+
"NoAssignmentInExpressions" : true,
44+
"NoBlockComments" : true,
45+
"NoCasesWithOnlyFallthrough" : true,
46+
"NoEmptyLinesOpeningClosingBraces" : false,
47+
"NoEmptyTrailingClosureParentheses" : true,
48+
"NoLabelsInCasePatterns" : true,
49+
"NoLeadingUnderscores" : false,
50+
"NoParensAroundConditions" : true,
51+
"NoPlaygroundLiterals" : true,
52+
"NoVoidReturnOnFunctionSignature" : true,
53+
"OmitExplicitReturns" : false,
54+
"OneCasePerLine" : true,
55+
"OneVariableDeclarationPerLine" : true,
56+
"OnlyOneTrailingClosureArgument" : true,
57+
"OrderedImports" : true,
58+
"ReplaceForEachWithForLoop" : true,
59+
"ReturnVoidInsteadOfEmptyTuple" : true,
60+
"TypeNamesShouldBeCapitalized" : true,
61+
"UseEarlyExits" : false,
62+
"UseExplicitNilCheckInConditions" : true,
63+
"UseLetInEveryBoundCaseVariable" : true,
64+
"UseShorthandTypeNames" : true,
65+
"UseSingleLinePropertyGetter" : true,
66+
"UseSynthesizedInitializer" : true,
67+
"UseTripleSlashForDocumentationComments" : true,
68+
"UseWhereClausesInForLoops" : false,
69+
"ValidateDocumentationComments" : false
70+
},
71+
"spacesAroundRangeFormationOperators" : false,
72+
"spacesBeforeEndOfLineComments" : 2,
73+
"tabWidth" : 4,
74+
"version" : 1
75+
}

ios/.swiftformat

Lines changed: 0 additions & 4 deletions
This file was deleted.

ios/AudioUtils.swift

Lines changed: 77 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -17,84 +17,86 @@
1717
import AVFoundation
1818

1919
public class AudioUtils {
20-
public static func audioSessionModeFromString(_ mode: String) -> AVAudioSession.Mode {
21-
let retMode: AVAudioSession.Mode = switch mode {
22-
case "default_":
23-
.default
24-
case "voicePrompt":
25-
if #available(iOS 12.0, *) {
26-
.voicePrompt
27-
} else {
28-
.default
29-
}
30-
case "videoRecording":
31-
.videoRecording
32-
case "videoChat":
33-
.videoChat
34-
case "voiceChat":
35-
.voiceChat
36-
case "gameChat":
37-
.gameChat
38-
case "measurement":
39-
.measurement
40-
case "moviePlayback":
41-
.moviePlayback
42-
case "spokenAudio":
43-
.spokenAudio
44-
default:
45-
.default
20+
public static func audioSessionModeFromString(_ mode: String) -> AVAudioSession.Mode {
21+
let retMode: AVAudioSession.Mode =
22+
switch mode {
23+
case "default_":
24+
.default
25+
case "voicePrompt":
26+
if #available(iOS 12.0, *) {
27+
.voicePrompt
28+
} else {
29+
.default
4630
}
47-
return retMode
48-
}
31+
case "videoRecording":
32+
.videoRecording
33+
case "videoChat":
34+
.videoChat
35+
case "voiceChat":
36+
.voiceChat
37+
case "gameChat":
38+
.gameChat
39+
case "measurement":
40+
.measurement
41+
case "moviePlayback":
42+
.moviePlayback
43+
case "spokenAudio":
44+
.spokenAudio
45+
default:
46+
.default
47+
}
48+
return retMode
49+
}
4950

50-
public static func audioSessionCategoryFromString(_ category: String) -> AVAudioSession.Category {
51-
let retCategory: AVAudioSession.Category = switch category {
52-
case "ambient":
53-
.ambient
54-
case "soloAmbient":
55-
.soloAmbient
56-
case "playback":
57-
.playback
58-
case "record":
59-
.record
60-
case "playAndRecord":
61-
.playAndRecord
62-
case "multiRoute":
63-
.multiRoute
64-
default:
65-
.soloAmbient
66-
}
67-
return retCategory
68-
}
51+
public static func audioSessionCategoryFromString(_ category: String) -> AVAudioSession.Category {
52+
let retCategory: AVAudioSession.Category =
53+
switch category {
54+
case "ambient":
55+
.ambient
56+
case "soloAmbient":
57+
.soloAmbient
58+
case "playback":
59+
.playback
60+
case "record":
61+
.record
62+
case "playAndRecord":
63+
.playAndRecord
64+
case "multiRoute":
65+
.multiRoute
66+
default:
67+
.soloAmbient
68+
}
69+
return retCategory
70+
}
6971

70-
public static func audioSessionCategoryOptionsFromStrings(_ options: [String]) -> AVAudioSession.CategoryOptions {
71-
var categoryOptions: AVAudioSession.CategoryOptions = []
72-
for option in options {
73-
switch option {
74-
case "mixWithOthers":
75-
categoryOptions.insert(.mixWithOthers)
76-
case "duckOthers":
77-
categoryOptions.insert(.duckOthers)
78-
case "allowBluetooth":
79-
categoryOptions.insert(.allowBluetooth)
80-
case "allowBluetoothA2DP":
81-
categoryOptions.insert(.allowBluetoothA2DP)
82-
case "allowAirPlay":
83-
categoryOptions.insert(.allowAirPlay)
84-
case "defaultToSpeaker":
85-
categoryOptions.insert(.defaultToSpeaker)
86-
case "interruptSpokenAudioAndMixWithOthers":
87-
if #available(iOS 13.0, *) {
88-
categoryOptions.insert(.interruptSpokenAudioAndMixWithOthers)
89-
}
90-
case "overrideMutedMicrophoneInterruption":
91-
if #available(iOS 14.5, *) {
92-
categoryOptions.insert(.overrideMutedMicrophoneInterruption)
93-
}
94-
default:
95-
break
96-
}
72+
public static func audioSessionCategoryOptionsFromStrings(_ options: [String]) -> AVAudioSession.CategoryOptions {
73+
var categoryOptions: AVAudioSession.CategoryOptions = []
74+
for option in options {
75+
switch option {
76+
case "mixWithOthers":
77+
categoryOptions.insert(.mixWithOthers)
78+
case "duckOthers":
79+
categoryOptions.insert(.duckOthers)
80+
case "allowBluetooth":
81+
categoryOptions.insert(.allowBluetooth)
82+
case "allowBluetoothA2DP":
83+
categoryOptions.insert(.allowBluetoothA2DP)
84+
case "allowAirPlay":
85+
categoryOptions.insert(.allowAirPlay)
86+
case "defaultToSpeaker":
87+
categoryOptions.insert(.defaultToSpeaker)
88+
case "interruptSpokenAudioAndMixWithOthers":
89+
if #available(iOS 13.0, *) {
90+
categoryOptions.insert(.interruptSpokenAudioAndMixWithOthers)
91+
}
92+
case "overrideMutedMicrophoneInterruption":
93+
if #available(iOS 14.5, *) {
94+
categoryOptions.insert(.overrideMutedMicrophoneInterruption)
9795
}
98-
return categoryOptions
96+
default:
97+
break
98+
}
9999
}
100+
return categoryOptions
101+
}
100102
}

0 commit comments

Comments
 (0)