mirror of
https://github.com/cranci1/Sora.git
synced 2026-03-11 17:45:37 +00:00
test label
This commit is contained in:
parent
b64f44c341
commit
54c75da756
3 changed files with 67 additions and 3 deletions
61
Sora/Utlis & Misc/Extensions/MarqueeText.swift
Normal file
61
Sora/Utlis & Misc/Extensions/MarqueeText.swift
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
//
|
||||||
|
// MarqueeText.swift
|
||||||
|
// Sulfur
|
||||||
|
//
|
||||||
|
// Created by Francesco on 25/06/25.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct MarqueeText: View {
|
||||||
|
let text: String
|
||||||
|
let font: Font
|
||||||
|
let color: Color
|
||||||
|
|
||||||
|
@State private var animate = false
|
||||||
|
@State private var textSize: CGSize = .zero
|
||||||
|
@State private var containerWidth: CGFloat = 0
|
||||||
|
|
||||||
|
init(_ text: String, font: Font = .body, color: Color = .white) {
|
||||||
|
self.text = text
|
||||||
|
self.font = font
|
||||||
|
self.color = color
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
GeometryReader { geometry in
|
||||||
|
if textSize.width > geometry.size.width {
|
||||||
|
ScrollView(.horizontal, showsIndicators: false) {
|
||||||
|
Text(text)
|
||||||
|
.font(font)
|
||||||
|
.foregroundColor(color)
|
||||||
|
.lineLimit(1)
|
||||||
|
.offset(x: animate ? -textSize.width - 20 : geometry.size.width)
|
||||||
|
.onAppear {
|
||||||
|
containerWidth = geometry.size.width
|
||||||
|
withAnimation(Animation.linear(duration: Double(textSize.width + containerWidth) / 30.0)
|
||||||
|
.repeatForever(autoreverses: false)) {
|
||||||
|
animate = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Text(text)
|
||||||
|
.font(font)
|
||||||
|
.foregroundColor(color)
|
||||||
|
.lineLimit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.background(
|
||||||
|
Text(text)
|
||||||
|
.font(font)
|
||||||
|
.lineLimit(1)
|
||||||
|
.hidden()
|
||||||
|
.background(GeometryReader { geometry in
|
||||||
|
Color.clear.onAppear {
|
||||||
|
textSize = geometry.size
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -57,9 +57,8 @@ struct SearchResultsGrid: View {
|
||||||
VStack {
|
VStack {
|
||||||
Spacer()
|
Spacer()
|
||||||
HStack {
|
HStack {
|
||||||
Text(item.title)
|
MarqueeText(item.title)
|
||||||
.lineLimit(2)
|
.frame(height: 20)
|
||||||
.foregroundColor(.white)
|
|
||||||
.multilineTextAlignment(.leading)
|
.multilineTextAlignment(.leading)
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@
|
||||||
138AA1B82D2D66FD0021F9DF /* EpisodeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138AA1B62D2D66FD0021F9DF /* EpisodeCell.swift */; };
|
138AA1B82D2D66FD0021F9DF /* EpisodeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138AA1B62D2D66FD0021F9DF /* EpisodeCell.swift */; };
|
||||||
138AA1B92D2D66FD0021F9DF /* CircularProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138AA1B72D2D66FD0021F9DF /* CircularProgressBar.swift */; };
|
138AA1B92D2D66FD0021F9DF /* CircularProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138AA1B72D2D66FD0021F9DF /* CircularProgressBar.swift */; };
|
||||||
138B66A02E0BEA52009BE8D9 /* WebAuthenticationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138B669F2E0BEA52009BE8D9 /* WebAuthenticationManager.swift */; };
|
138B66A02E0BEA52009BE8D9 /* WebAuthenticationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138B669F2E0BEA52009BE8D9 /* WebAuthenticationManager.swift */; };
|
||||||
|
138B66A42E0BEF64009BE8D9 /* MarqueeText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138B66A32E0BEF64009BE8D9 /* MarqueeText.swift */; };
|
||||||
138FE1D02DECA00D00936D81 /* TMDB-FetchID.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138FE1CF2DECA00D00936D81 /* TMDB-FetchID.swift */; };
|
138FE1D02DECA00D00936D81 /* TMDB-FetchID.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138FE1CF2DECA00D00936D81 /* TMDB-FetchID.swift */; };
|
||||||
1398FB3F2DE4E161004D3F5F /* SettingsViewAbout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1398FB3E2DE4E161004D3F5F /* SettingsViewAbout.swift */; };
|
1398FB3F2DE4E161004D3F5F /* SettingsViewAbout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1398FB3E2DE4E161004D3F5F /* SettingsViewAbout.swift */; };
|
||||||
139935662D468C450065CEFF /* ModuleManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 139935652D468C450065CEFF /* ModuleManager.swift */; };
|
139935662D468C450065CEFF /* ModuleManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 139935652D468C450065CEFF /* ModuleManager.swift */; };
|
||||||
|
|
@ -190,6 +191,7 @@
|
||||||
138AA1B62D2D66FD0021F9DF /* EpisodeCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EpisodeCell.swift; sourceTree = "<group>"; };
|
138AA1B62D2D66FD0021F9DF /* EpisodeCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EpisodeCell.swift; sourceTree = "<group>"; };
|
||||||
138AA1B72D2D66FD0021F9DF /* CircularProgressBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CircularProgressBar.swift; sourceTree = "<group>"; };
|
138AA1B72D2D66FD0021F9DF /* CircularProgressBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CircularProgressBar.swift; sourceTree = "<group>"; };
|
||||||
138B669F2E0BEA52009BE8D9 /* WebAuthenticationManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebAuthenticationManager.swift; sourceTree = "<group>"; };
|
138B669F2E0BEA52009BE8D9 /* WebAuthenticationManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebAuthenticationManager.swift; sourceTree = "<group>"; };
|
||||||
|
138B66A32E0BEF64009BE8D9 /* MarqueeText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarqueeText.swift; sourceTree = "<group>"; };
|
||||||
138FE1CF2DECA00D00936D81 /* TMDB-FetchID.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TMDB-FetchID.swift"; sourceTree = "<group>"; };
|
138FE1CF2DECA00D00936D81 /* TMDB-FetchID.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TMDB-FetchID.swift"; sourceTree = "<group>"; };
|
||||||
1398FB3E2DE4E161004D3F5F /* SettingsViewAbout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewAbout.swift; sourceTree = "<group>"; };
|
1398FB3E2DE4E161004D3F5F /* SettingsViewAbout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewAbout.swift; sourceTree = "<group>"; };
|
||||||
139935652D468C450065CEFF /* ModuleManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModuleManager.swift; sourceTree = "<group>"; };
|
139935652D468C450065CEFF /* ModuleManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModuleManager.swift; sourceTree = "<group>"; };
|
||||||
|
|
@ -602,6 +604,7 @@
|
||||||
136BBE7F2DB1038000906B5E /* Notification+Name.swift */,
|
136BBE7F2DB1038000906B5E /* Notification+Name.swift */,
|
||||||
1327FBA82D758DEA00FC6689 /* UIDevice+Model.swift */,
|
1327FBA82D758DEA00FC6689 /* UIDevice+Model.swift */,
|
||||||
13637B892DE0EA1100BDA2FC /* UserDefaults.swift */,
|
13637B892DE0EA1100BDA2FC /* UserDefaults.swift */,
|
||||||
|
138B66A32E0BEF64009BE8D9 /* MarqueeText.swift */,
|
||||||
133D7C872D2BE2640075467E /* URLSession.swift */,
|
133D7C872D2BE2640075467E /* URLSession.swift */,
|
||||||
1359ED132D76F49900C13034 /* finTopView.swift */,
|
1359ED132D76F49900C13034 /* finTopView.swift */,
|
||||||
13CBEFD92D5F7D1200D011EE /* String.swift */,
|
13CBEFD92D5F7D1200D011EE /* String.swift */,
|
||||||
|
|
@ -972,6 +975,7 @@
|
||||||
130C6BFA2D53AB1F00DC1432 /* SettingsViewData.swift in Sources */,
|
130C6BFA2D53AB1F00DC1432 /* SettingsViewData.swift in Sources */,
|
||||||
0402DA172DE7B7B8003BB42C /* SearchViewComponents.swift in Sources */,
|
0402DA172DE7B7B8003BB42C /* SearchViewComponents.swift in Sources */,
|
||||||
1E9FF1D32D403E49008AC100 /* SettingsViewLoggerFilter.swift in Sources */,
|
1E9FF1D32D403E49008AC100 /* SettingsViewLoggerFilter.swift in Sources */,
|
||||||
|
138B66A42E0BEF64009BE8D9 /* MarqueeText.swift in Sources */,
|
||||||
0402DA0E2DE7AA01003BB42C /* TabBarController.swift in Sources */,
|
0402DA0E2DE7AA01003BB42C /* TabBarController.swift in Sources */,
|
||||||
1E47859B2DEBC5960095BF2F /* AnilistMatchPopupView.swift in Sources */,
|
1E47859B2DEBC5960095BF2F /* AnilistMatchPopupView.swift in Sources */,
|
||||||
13EA2BD92D32D98400C1EBD7 /* NormalPlayer.swift in Sources */,
|
13EA2BD92D32D98400C1EBD7 /* NormalPlayer.swift in Sources */,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue