Skip to content

Commit

Permalink
Merge pull request #235 from shiguredo/feature/swift-format-default
Browse files Browse the repository at this point in the history
swift-format をデフォルト設定で利用するように変更 & フォーマット適用
  • Loading branch information
zztkm authored Feb 12, 2025
2 parents 9f8e15c + ef28499 commit db663aa
Show file tree
Hide file tree
Showing 41 changed files with 6,079 additions and 6,149 deletions.
71 changes: 0 additions & 71 deletions .swift-format

This file was deleted.

2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
### misc

- [CHANGE] フォーマッターを swift-format に移行する
- SwiftFormat のための設定ファイルである .swiftformat と .swift-version を削除
- フォーマット設定はデフォルトを採用したため、.swift-format は利用しない
- @zztkm
- [UPDATE] GitHub Actions で format check をするのをやめる
- @zztkm
Expand Down
54 changes: 27 additions & 27 deletions Sora/AspectRatio.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,42 @@ import UIKit

/// :nodoc:
public enum AspectRatio {
case standard // 4:3
case wide // 16:9
case standard // 4:3
case wide // 16:9

public func height(forWidth width: CGFloat) -> CGFloat {
switch self {
case .standard:
return width / 4 * 3
case .wide:
return width / 16 * 9
}
public func height(forWidth width: CGFloat) -> CGFloat {
switch self {
case .standard:
return width / 4 * 3
case .wide:
return width / 16 * 9
}
}

public func size(forWidth width: CGFloat) -> CGSize {
CGSize(width: width, height: height(forWidth: width))
}
public func size(forWidth width: CGFloat) -> CGSize {
CGSize(width: width, height: height(forWidth: width))
}

public func scale(size: CGSize) -> CGSize {
self.size(forWidth: size.width)
}
public func scale(size: CGSize) -> CGSize {
self.size(forWidth: size.width)
}
}

private var aspectRatioTable: PairTable<String, AspectRatio> =
PairTable(
name: "AspectRatio",
pairs: [
("standard", .standard),
("wide", .wide),
])
PairTable(
name: "AspectRatio",
pairs: [
("standard", .standard),
("wide", .wide),
])

/// :nodoc:
extension AspectRatio: Codable {
public init(from decoder: Decoder) throws {
self = try aspectRatioTable.decode(from: decoder)
}
public init(from decoder: Decoder) throws {
self = try aspectRatioTable.decode(from: decoder)
}

public func encode(to encoder: Encoder) throws {
try aspectRatioTable.encode(self, to: encoder)
}
public func encode(to encoder: Encoder) throws {
try aspectRatioTable.encode(self, to: encoder)
}
}
46 changes: 23 additions & 23 deletions Sora/AudioCodec.swift
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
import Foundation

private let descriptionTable: PairTable<String, AudioCodec> =
PairTable(
name: "AudioCodec",
pairs: [
("default", .default),
("OPUS", .opus),
("PCMU", .pcmu),
])
PairTable(
name: "AudioCodec",
pairs: [
("default", .default),
("OPUS", .opus),
("PCMU", .pcmu),
])

/// 音声コーデックを表します。
public enum AudioCodec {
/**
/**
サーバーが指定するデフォルトのコーデック。
現在のデフォルトのコーデックは Opus です。
*/
case `default`
case `default`

/// Opus
case opus
/// Opus
case opus

/// PCMU
case pcmu
/// PCMU
case pcmu
}

extension AudioCodec: CustomStringConvertible {
/// 文字列表現を返します。
public var description: String {
descriptionTable.left(other: self)!
}
/// 文字列表現を返します。
public var description: String {
descriptionTable.left(other: self)!
}
}

/// :nodoc:
extension AudioCodec: Codable {
public init(from decoder: Decoder) throws {
self = try descriptionTable.decode(from: decoder)
}
public init(from decoder: Decoder) throws {
self = try descriptionTable.decode(from: decoder)
}

public func encode(to encoder: Encoder) throws {
try descriptionTable.encode(self, to: encoder)
}
public func encode(to encoder: Encoder) throws {
try descriptionTable.encode(self, to: encoder)
}
}
34 changes: 17 additions & 17 deletions Sora/AudioMode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation
/// - ``allowBluetoothA2DP``
/// - ``allowAirPlay``
public enum AudioMode {
/**
/**
* デフォルト。
* ``AVAudioSession`` の音声モードを ``default`` に変更します。
* 音声カテゴリを ``category`` の値に変更します。
Expand All @@ -21,40 +21,40 @@ public enum AudioMode {
* - parameter category: 音声カテゴリ
* - parameter output: 音声出力先
*/
case `default`(category: AVAudioSession.Category, output: AudioOutput)
case `default`(category: AVAudioSession.Category, output: AudioOutput)

/**
/**
* ビデオチャット。
* ``AVAudioSession`` の音声モードを ``videoChat`` に変更します。
* 音声カテゴリを ``playAndRecord`` に変更します。
* 音声はスピーカーから出力されます。
*/
case videoChat
case videoChat

/**
/**
* ボイスチャット。
* ``AVAudioSession`` の音声モードを ``voiceChat`` に変更します。
* 音声カテゴリを ``playAndRecord`` に変更します。
*
* - parameter output: 音声出力先
*/
case voiceChat(output: AudioOutput)
case voiceChat(output: AudioOutput)
}

/// 音声出力先
public enum AudioOutput {
/// デフォルト。端末の状態に依存します。
case `default`
/// デフォルト。端末の状態に依存します。
case `default`

/// スピーカー
case speaker
/// スピーカー
case speaker

var portOverride: AVAudioSession.PortOverride {
switch self {
case .default:
return .none
case .speaker:
return .speaker
}
var portOverride: AVAudioSession.PortOverride {
switch self {
case .default:
return .none
case .speaker:
return .speaker
}
}
}
Loading

0 comments on commit db663aa

Please sign in to comment.