Skip to content

Commit 530f07f

Browse files
committed
setup locale as optional
1 parent 6008ad2 commit 530f07f

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

Sources/BuilderIO/ExportedView/BuilderIOContentView.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ public struct BuilderIOContentView: View {
99
@State private var viewModel: BuilderIOViewModel
1010
@Binding var locale: String
1111

12+
public init(model: String, locale: String) {
13+
self.init(model: model, locale: .constant(locale))
14+
}
15+
1216
public init(model: String, locale: Binding<String>) {
1317
self.model = model
1418
self.url = nil
@@ -17,6 +21,10 @@ public struct BuilderIOContentView: View {
1721

1822
}
1923

24+
public init(url: String, model: String = "page", locale: String) {
25+
self.init(url: url, model: model, locale: .constant(locale))
26+
}
27+
2028
init(url: String, model: String = "page", locale: Binding<String>) {
2129
self.url = url
2230
self.model = model

Sources/BuilderIO/ExportedView/BuilderIOPage.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public struct BuilderIOPage: View {
55

66
let url: String
77
let model: String
8-
@State private var locale: String
8+
@Binding var locale: String
99

1010
@StateObject private var buttonActionManager = BuilderActionManager()
1111
var onClickEventHandler: ((BuilderAction) -> Void)? = nil
@@ -15,15 +15,19 @@ public struct BuilderIOPage: View {
1515
public init(
1616
url: String, model: String = "page", locale: String = "Default",
1717
onClickEventHandler: ((BuilderAction) -> Void)? = nil
18+
) {
19+
self.init(
20+
url: url, model: model, locale: .constant(locale), onClickEventHandler: onClickEventHandler)
21+
}
22+
23+
public init(
24+
url: String, model: String = "page", locale: Binding<String>,
25+
onClickEventHandler: ((BuilderAction) -> Void)? = nil
1826
) {
1927
self.url = url
2028
self.model = model
2129
self.onClickEventHandler = onClickEventHandler
22-
self._locale = State(initialValue: locale)
23-
}
24-
25-
public func updateLocale(locale: String) {
26-
30+
self._locale = locale
2731
}
2832

2933
public var body: some View {

0 commit comments

Comments
 (0)