-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from gzerad/feature/end-call-feedback
Implement call end feedback
- Loading branch information
Showing
9 changed files
with
462 additions
and
4 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
23 changes: 23 additions & 0 deletions
23
Sources/HMSRoomKit/Media.xcassets/user-music.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,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "User Music.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "User Music 1.png", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "User Music 2.png", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+2.83 KB
Sources/HMSRoomKit/Media.xcassets/user-music.imageset/User Music 1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.25 KB
Sources/HMSRoomKit/Media.xcassets/user-music.imageset/User Music 2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,99 @@ | ||
// | ||
// FlexibleView.swift | ||
// HMSRoomKitPreview | ||
// | ||
// Created by Pawan Dixit on 7/29/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct FlexibleView<Data: Collection, Content: View>: View where Data.Element: Hashable { | ||
let data: Data | ||
let spacing: CGFloat | ||
let alignment: HorizontalAlignment | ||
let content: (Data.Element) -> Content | ||
@State private var availableWidth: CGFloat = 0 | ||
|
||
var body: some View { | ||
ZStack(alignment: Alignment(horizontal: alignment, vertical: .center)) { | ||
Color.clear | ||
.frame(height: 1) | ||
.readSize { size in | ||
availableWidth = size.width | ||
} | ||
|
||
_FlexibleView( | ||
availableWidth: availableWidth, | ||
data: data, | ||
spacing: spacing, | ||
alignment: alignment, | ||
content: content | ||
) | ||
} | ||
} | ||
} | ||
|
||
struct _FlexibleView<Data: Collection, Content: View>: View where Data.Element: Hashable { | ||
let availableWidth: CGFloat | ||
let data: Data | ||
let spacing: CGFloat | ||
let alignment: HorizontalAlignment | ||
let content: (Data.Element) -> Content | ||
@State var elementsSize: [Data.Element: CGSize] = [:] | ||
|
||
var body : some View { | ||
VStack(alignment: alignment, spacing: spacing) { | ||
ForEach(computeRows(), id: \.self) { rowElements in | ||
HStack(spacing: spacing) { | ||
ForEach(rowElements, id: \.self) { element in | ||
content(element) | ||
.fixedSize() | ||
.readSize { size in | ||
elementsSize[element] = size | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
func computeRows() -> [[Data.Element]] { | ||
var rows: [[Data.Element]] = [[]] | ||
var currentRow = 0 | ||
var remainingWidth = availableWidth | ||
|
||
for element in data { | ||
let elementSize = elementsSize[element, default: CGSize(width: availableWidth, height: 1)] | ||
|
||
if remainingWidth - (elementSize.width + spacing) >= 0 { | ||
rows[currentRow].append(element) | ||
} else { | ||
currentRow = currentRow + 1 | ||
rows.append([element]) | ||
remainingWidth = availableWidth | ||
} | ||
|
||
remainingWidth = remainingWidth - (elementSize.width + spacing) | ||
} | ||
|
||
return rows | ||
} | ||
} | ||
|
||
extension View { | ||
func readSize(onChange: @escaping (CGSize) -> Void) -> some View { | ||
background( | ||
GeometryReader { geometryProxy in | ||
Color.clear | ||
.preference(key: HMSSizePreferenceKey.self, value: geometryProxy.size) | ||
} | ||
) | ||
.onPreferenceChange(HMSSizePreferenceKey.self, perform: onChange) | ||
} | ||
} | ||
|
||
private struct HMSSizePreferenceKey: PreferenceKey { | ||
static var defaultValue: CGSize = .zero | ||
static func reduce(value: inout CGSize, nextValue: () -> CGSize) {} | ||
} | ||
|
Oops, something went wrong.