-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
1,364 additions
and
284 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,66 @@ | ||
// | ||
// CustomThumbnailSlider.swift | ||
// Tella | ||
// | ||
// Created by RIMA on 15.11.24. | ||
// Copyright © 2024 HORIZONTAL. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct CustomThumbnailSlider: View { | ||
|
||
//MARK: - Private Attributes | ||
@State private var isEditing = false | ||
private let kOffset = 3.0 | ||
|
||
@Binding var value: Double | ||
var range: ClosedRange<Double> | ||
|
||
var sliderHeight = 200.0 | ||
var sliderWidth = 10.0 | ||
var sliderImage: String | ||
|
||
var onEditingChanged: ((Bool) -> Void)? | ||
|
||
var body: some View { | ||
GeometryReader { geometry in | ||
sliderImage(in: geometry) | ||
.gesture(dragGesture(in: geometry)) | ||
} | ||
} | ||
|
||
// Extract slider image view with offset calculation | ||
private func sliderImage(in geometry: GeometryProxy) -> some View { | ||
ResizableImage(sliderImage) | ||
.frame(width: sliderWidth) | ||
.offset(x: calculateThumbOffset(in: geometry), y: -10) | ||
} | ||
// Drag gesture with adjusted conditions for limit scrolling | ||
private func dragGesture(in geometry: GeometryProxy) -> some Gesture { | ||
DragGesture(minimumDistance: 0) | ||
.onChanged { dragValue in | ||
let newValue = Double(dragValue.location.x / geometry.size.width) * (range.upperBound - range.lowerBound) + range.lowerBound | ||
value = min(max(newValue, range.lowerBound), range.upperBound) | ||
} | ||
.onEnded { _ in | ||
if isEditing { | ||
onEditingChanged?(false) // Call closure when editing ends | ||
isEditing = false | ||
} | ||
} | ||
.onChanged { _ in | ||
if !isEditing { | ||
onEditingChanged?(true) // Call closure when editing starts | ||
isEditing = true | ||
} | ||
} | ||
} | ||
// Calculate the offset for the thumb | ||
private func calculateThumbOffset(in geometry: GeometryProxy) -> CGFloat { | ||
CGFloat((value - range.lowerBound) / (range.upperBound - range.lowerBound)) * geometry.size.width - kOffset | ||
} | ||
|
||
} | ||
|
||
|
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,23 @@ | ||
// | ||
// ResizableImage.swift | ||
// Tella | ||
// | ||
// Created by RIMA on 14.11.24. | ||
// Copyright © 2024 HORIZONTAL. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct ResizableImage: View { | ||
var name: String | ||
|
||
init(_ name: String) { | ||
self.name = name | ||
} | ||
|
||
var body: some View { | ||
Image(name) | ||
.resizable() | ||
} | ||
} | ||
|
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 |
---|---|---|
|
@@ -27,4 +27,5 @@ enum FileSource { | |
enum FileExtension : String { | ||
case heic = "heic" | ||
case mov = "mov" | ||
case mp4 = "mp4" | ||
} |
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
12 changes: 12 additions & 0 deletions
12
Tella/NewAssets.xcassets/edit.video.left.icon.imageset/Contents.json
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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "edit.video.left.icon.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+1.37 KB
Tella/NewAssets.xcassets/edit.video.left.icon.imageset/edit.video.left.icon.pdf
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
Tella/NewAssets.xcassets/edit.video.play.line.imageset/Contents.json
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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "edit.video.play.line.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+1.09 KB
Tella/NewAssets.xcassets/edit.video.play.line.imageset/edit.video.play.line.pdf
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
Tella/NewAssets.xcassets/edit.video.right.icon.imageset/Contents.json
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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "edit.video.right.icon.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+1.37 KB
Tella/NewAssets.xcassets/edit.video.right.icon.imageset/edit.video.right.icon.pdf
Binary file not shown.
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
Oops, something went wrong.