forked from jellyfin/Swiftfin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS] Admin Dashboard - User Permissions (jellyfin#1313)
* WIP * WIP * Localization and better planning. Remove the Username as this will end up in another section. Updated planning here: jellyfin#1283 | 5 more views required! * Initializing an optional variable with nil is redundant line * Remove Live TV since that will go in another section * Cleanup Coordinator / Merge with Main * Remove all 'Allows' from strings * Fix Merge Issues * Use CaseIterablePicker, Binding.map * BackgroundState == updating, change all of the buttons to visible when custom by process of elimination opposed to the default custom value. Make all of the input fields use temp values to make it less jarring. * Update SessionsSection.swift * Learn more! * Validate > 0, don't allow inputs to be less than 1 and reset tempValues when the enum is updated. * use new binding extensions * String fixes * Don't test against adminDefault for users or userDefault for admins. * Linting indentation * Default vs UserDefault + no more reason to have temporary variables. * cleanup * format --------- Co-authored-by: Ethan Pippin <[email protected]>
- Loading branch information
Showing
23 changed files
with
1,307 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// Swiftfin is subject to the terms of the Mozilla Public | ||
// License, v2.0. If a copy of the MPL was not distributed with this | ||
// file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) 2024 Jellyfin & Jellyfin Contributors | ||
// | ||
|
||
import SwiftUI | ||
|
||
extension Binding { | ||
|
||
func clamp(min: Value, max: Value) -> Binding<Value> where Value: Comparable { | ||
Binding<Value>( | ||
get: { Swift.min(Swift.max(wrappedValue, min), max) }, | ||
set: { wrappedValue = Swift.min(Swift.max($0, min), max) } | ||
) | ||
} | ||
|
||
func coalesce<T>(_ defaultValue: T) -> Binding<T> where Value == T? { | ||
Binding<T>( | ||
get: { wrappedValue ?? defaultValue }, | ||
set: { wrappedValue = $0 } | ||
) | ||
} | ||
|
||
func map<V>(getter: @escaping (Value) -> V, setter: @escaping (V) -> Value) -> Binding<V> { | ||
Binding<V>( | ||
get: { getter(wrappedValue) }, | ||
set: { wrappedValue = setter($0) } | ||
) | ||
} | ||
|
||
func min(_ minValue: Value) -> Binding<Value> where Value: Comparable { | ||
Binding<Value>( | ||
get: { Swift.max(wrappedValue, minValue) }, | ||
set: { wrappedValue = Swift.max($0, minValue) } | ||
) | ||
} | ||
|
||
func negate() -> Binding<Bool> where Value == Bool { | ||
map(getter: { !$0 }, setter: { $0 }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// Swiftfin is subject to the terms of the Mozilla Public | ||
// License, v2.0. If a copy of the MPL was not distributed with this | ||
// file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) 2024 Jellyfin & Jellyfin Contributors | ||
// | ||
|
||
import Foundation | ||
|
||
enum ActiveSessionsPolicy: Int, Displayable, CaseIterable { | ||
|
||
case unlimited = 0 | ||
case custom = 1 // Default to 1 Active Session | ||
|
||
// MARK: - Display Title | ||
|
||
var displayTitle: String { | ||
switch self { | ||
case .unlimited: | ||
return L10n.unlimited | ||
case .custom: | ||
return L10n.custom | ||
} | ||
} | ||
|
||
init?(rawValue: Int?) { | ||
guard let rawValue else { return nil } | ||
self.init(rawValue: rawValue) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// Swiftfin is subject to the terms of the Mozilla Public | ||
// License, v2.0. If a copy of the MPL was not distributed with this | ||
// file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) 2024 Jellyfin & Jellyfin Contributors | ||
// | ||
|
||
import Foundation | ||
|
||
enum LoginFailurePolicy: Int, Displayable, CaseIterable { | ||
|
||
case unlimited = -1 | ||
case userDefault = 0 | ||
case custom = 1 // Default to 1 | ||
|
||
var displayTitle: String { | ||
switch self { | ||
case .unlimited: | ||
return L10n.unlimited | ||
case .userDefault: | ||
return L10n.default | ||
case .custom: | ||
return L10n.custom | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// Swiftfin is subject to the terms of the Mozilla Public | ||
// License, v2.0. If a copy of the MPL was not distributed with this | ||
// file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) 2024 Jellyfin & Jellyfin Contributors | ||
// | ||
|
||
import Foundation | ||
|
||
enum MaxBitratePolicy: Int, Displayable, CaseIterable { | ||
|
||
case unlimited = 0 | ||
case custom = 10_000_000 // Default to 10mbps | ||
|
||
// MARK: - Display Title | ||
|
||
var displayTitle: String { | ||
switch self { | ||
case .unlimited: | ||
return L10n.unlimited | ||
case .custom: | ||
return L10n.custom | ||
} | ||
} | ||
|
||
init?(rawValue: Int?) { | ||
guard let rawValue else { return nil } | ||
self.init(rawValue: rawValue) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Shared/Extensions/JellyfinAPI/SyncPlayUserAccessType.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// Swiftfin is subject to the terms of the Mozilla Public | ||
// License, v2.0. If a copy of the MPL was not distributed with this | ||
// file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) 2024 Jellyfin & Jellyfin Contributors | ||
// | ||
|
||
import Foundation | ||
import JellyfinAPI | ||
|
||
extension SyncPlayUserAccessType: Displayable { | ||
|
||
var displayTitle: String { | ||
switch self { | ||
case .createAndJoinGroups: | ||
L10n.createAndJoinGroups | ||
case .joinGroups: | ||
L10n.joinGroups | ||
case .none: | ||
L10n.none | ||
} | ||
} | ||
} |
Oops, something went wrong.