Skip to content

Commit

Permalink
Chat bottom setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
eerimoq committed Jan 4, 2025
1 parent a54b6a6 commit f4df11b
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 28 deletions.
3 changes: 3 additions & 0 deletions Common/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -26883,6 +26883,9 @@
}
}
}
},
"Bottom" : {

},
"Bottom right" : {
"localizations" : {
Expand Down
5 changes: 5 additions & 0 deletions Moblin/Various/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1720,6 +1720,7 @@ class SettingsChat: Codable {
var badges: Bool? = true
var showFirstTimeChatterMessage: Bool? = true
var showNewFollowerMessage: Bool? = true
var bottom: Double? = 0.0
}

enum SettingsMic: String, Codable, CaseIterable {
Expand Down Expand Up @@ -4441,5 +4442,9 @@ final class Settings {
realDatabase.debug.srtlaBatchSend = false
store()
}
if realDatabase.chat.bottom == nil {
realDatabase.chat.bottom = 0.0
store()
}
}
}
4 changes: 2 additions & 2 deletions Moblin/View/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ struct MainView: View {
.ignoresSafeArea()
.edgesIgnoringSafeArea(.all)
GeometryReader { metrics in
StreamOverlayView(width: metrics.size.width)
StreamOverlayView(width: metrics.size.width, height: metrics.size.height)
.opacity(model.showLocalOverlays ? 1 : 0)
}
if model.showFace && !model.showDrawOnStream {
Expand Down Expand Up @@ -346,7 +346,7 @@ struct MainView: View {
.ignoresSafeArea()
.edgesIgnoringSafeArea(.all)
GeometryReader { metrics in
StreamOverlayView(width: metrics.size.width)
StreamOverlayView(width: metrics.size.width, height: metrics.size.height)
.opacity(model.showLocalOverlays ? 1 : 0)
}
if model.showDrawOnStream {
Expand Down
25 changes: 23 additions & 2 deletions Moblin/View/Settings/Chat/ChatSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct ChatSettingsView: View {
@State var shadowColor: Color
@State var height: Double
@State var width: Double
@State var bottom: Double
@State var fontSize: Float

func submitMaximumAge(value: String) {
Expand Down Expand Up @@ -171,7 +172,7 @@ struct ChatSettingsView: View {
Slider(
value: $height,
in: 0.2 ... 1.0,
step: 0.05,
step: 0.01,
onEditingChanged: { begin in
guard !begin else {
return
Expand All @@ -191,7 +192,7 @@ struct ChatSettingsView: View {
Slider(
value: $width,
in: 0.2 ... 1.0,
step: 0.05,
step: 0.01,
onEditingChanged: { begin in
guard !begin else {
return
Expand All @@ -206,6 +207,26 @@ struct ChatSettingsView: View {
Text("\(Int(100 * width)) %")
.frame(width: 55)
}
HStack {
Text("Bottom")
Slider(
value: $bottom,
in: 0.0 ... 0.5,
step: 0.01,
onEditingChanged: { begin in
guard !begin else {
return
}
model.database.chat.bottom = bottom
model.reloadChatMessages()
}
)
.onChange(of: bottom) { value in
model.database.chat.bottom = value
}
Text("\(Int(100 * bottom)) %")
.frame(width: 55)
}
}
if model.database.showAllSettings! {
Section {
Expand Down
1 change: 1 addition & 0 deletions Moblin/View/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ struct SettingsView: View {
shadowColor: chat.shadowColor.color(),
height: chat.height!,
width: chat.width!,
bottom: chat.bottom!,
fontSize: chat.fontSize
)
} label: {
Expand Down
61 changes: 37 additions & 24 deletions Moblin/View/Stream/StreamOverlayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,46 @@ struct ChatInfo: View {
}
}

private struct ChatPausedView: View {
@EnvironmentObject var model: Model

var body: some View {
if model.chatPaused {
ChatInfo(
message: String(localized: "Chat paused: \(model.pausedChatPostsCount) new messages")
)
.padding(2)
}
}
}

private struct ChatOverlayView: View {
@EnvironmentObject var model: Model
let height: CGFloat

var body: some View {
ZStack {
if model.stream.portrait! || model.database.portrait! {
VStack {
StreamOverlayChatView()
Rectangle()
.foregroundColor(.clear)
.frame(height: 85)
}
} else {
GeometryReader { metrics in
if model.stream.portrait! || model.database.portrait! {
VStack {
ZStack {
StreamOverlayChatView()
.frame(width: metrics.size.width * 0.95)
ChatPausedView()
}
Rectangle()
.foregroundColor(.clear)
.frame(height: 85)
}
if model.chatPaused {
ChatInfo(
message: String(localized: "Chat paused: \(model.pausedChatPostsCount) new messages")
)
.padding(2)
} else {
VStack {
ZStack {
GeometryReader { metrics in
StreamOverlayChatView()
.frame(width: metrics.size.width * 0.95)
}
ChatPausedView()
}
Rectangle()
.foregroundColor(.clear)
.frame(height: height * model.database.chat.bottom!)
}
}
}
Expand Down Expand Up @@ -112,6 +129,7 @@ private struct FrontTorchView: View {
struct StreamOverlayView: View {
@EnvironmentObject var model: Model
let width: CGFloat
let height: CGFloat

private func leadingPadding() -> CGFloat {
if UIDevice.current
Expand All @@ -129,20 +147,15 @@ struct StreamOverlayView: View {
FrontTorchView()
}
ZStack {
if model.showingPanel != .chat, model.interactiveChat {
ChatOverlayView()
if model.showingPanel != .chat {
ChatOverlayView(height: height)
.opacity(model.database.chat.enabled! ? 1 : 0)
.allowsHitTesting(true)
.allowsHitTesting(model.interactiveChat)
}
HStack {
Spacer()
RightOverlayBottomView(width: width)
}
if model.showingPanel != .chat, !model.interactiveChat {
ChatOverlayView()
.opacity(model.database.chat.enabled! ? 1 : 0)
.allowsHitTesting(false)
}
HStack {
LeftOverlayView()
.padding([.leading], leadingPadding())
Expand Down

0 comments on commit f4df11b

Please sign in to comment.