aboutsummaryrefslogtreecommitdiff
path: root/Sources/SwiftLVGL/Widgets/LVGLSpinner.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Sources/SwiftLVGL/Widgets/LVGLSpinner.swift')
-rw-r--r--Sources/SwiftLVGL/Widgets/LVGLSpinner.swift30
1 files changed, 28 insertions, 2 deletions
diff --git a/Sources/SwiftLVGL/Widgets/LVGLSpinner.swift b/Sources/SwiftLVGL/Widgets/LVGLSpinner.swift
index a806437..9a97bb2 100644
--- a/Sources/SwiftLVGL/Widgets/LVGLSpinner.swift
+++ b/Sources/SwiftLVGL/Widgets/LVGLSpinner.swift
@@ -1,8 +1,34 @@
//
-// File.swift
+// LVGLSpinner.swift
//
//
// Created by Navan Chauhan on 8/9/24.
//
-import Foundation
+import CLVGL
+
+public protocol LVGLSpinnerProtocol: LVGLObjectProtocol {
+ func setAnimation(animationTime: UInt32, arcAngle: UInt32)
+}
+
+public struct LVGLSpinner: LVGLSpinnerProtocol {
+ public var pointer: UnsafeMutablePointer<lv_obj_t>?
+
+ public init(
+ animationTime: UInt32 = 100,
+ arcAngle: UInt32 = 200, alignment: LVAlignment = .center, xSize: UInt32 = 100,
+ ySize: UInt32 = 100
+ ) {
+ guard let spinner = lv_spinner_create(lv_screen_active()) else {
+ fatalError("Failed to create spinner")
+ }
+ self.pointer = spinner
+ align(alignment: alignment)
+ setSize(width: 100, height: 100)
+ lv_spinner_set_anim_params(spinner, 1000, 200)
+ }
+
+ public func setAnimation(animationTime: UInt32 = 1000, arcAngle: UInt32 = 200) {
+ lv_spinner_set_anim_params(pointer, animationTime, arcAngle)
+ }
+}