jellyflood/Swiftfin/Views/AdminDashboardView/AddTaskTriggerView/Components/IntervalRow.swift
Joe bcc1b6e733
[iOS] Admin Dashboard - Migrate to Own Coordinator/Folder (#1300)
* Migrate all files from UserDashboard to AdminDashboard. Rename accordingly since this is an admin only function. Move all AdminDashboard items from SettingsCoordinator to their own AdminDashboardCoordinator. Move all ViewModels to ONLY live inside of the iOS build since tvOS is

* cleanup

* fix for sub navigation

---------

Co-authored-by: Ethan Pippin <ethanpippin2343@gmail.com>
2024-11-04 14:14:22 -07:00

61 lines
1.8 KiB
Swift

//
// 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 JellyfinAPI
import SwiftUI
extension AddTaskTriggerView {
struct IntervalRow: View {
@Binding
private var taskTriggerInfo: TaskTriggerInfo
@State
private var tempInterval: Int?
// MARK: - Init
init(taskTriggerInfo: Binding<TaskTriggerInfo>) {
self._taskTriggerInfo = taskTriggerInfo
_tempInterval = State(initialValue: Int(ServerTicks(taskTriggerInfo.wrappedValue.intervalTicks).minutes))
}
// MARK: - Body
var body: some View {
ChevronAlertButton(
L10n.every,
subtitle: ServerTicks(
taskTriggerInfo.intervalTicks
).seconds.formatted(.hourMinute),
description: L10n.taskTriggerInterval
) {
TextField(
L10n.minutes,
value: $tempInterval,
format: .number
)
.keyboardType(.numberPad)
} onSave: {
if tempInterval != nil && tempInterval != 0 {
taskTriggerInfo.intervalTicks = ServerTicks(minutes: tempInterval).ticks
} else {
taskTriggerInfo.intervalTicks = nil
}
} onCancel: {
if let intervalTicks = taskTriggerInfo.intervalTicks {
tempInterval = Int(ServerTicks(intervalTicks).minutes)
} else {
tempInterval = nil
}
}
}
}
}