SwiftWebUI icon indicating copy to clipboard operation
SwiftWebUI copied to clipboard

The height of the root view should match the available browser height (was: Access to page color)

Open vBoykoGit opened this issue 5 years ago • 4 comments

Hi, I have the following code:

struct MainPage: View {
    var body: some View {
        return VStack {
            OrderHistory(previousOrders: previousOrders)
        } .background(.black, cornerRadius: nil)
            .padding(0)
            .relativeWidth(1)
            .relativeHeight(1)
    }
}

Now the page looks like that: Снимок экрана 2020-05-16 в 15 35 03 How can I access the page color? I want the full black page.

vBoykoGit avatar May 16 '20 12:05 vBoykoGit

The HTML body is not yet exposed: https://github.com/SwiftWebUI/SwiftWebUI/blob/develop/Sources/SwiftWebUI/ViewHosting/NIOHostingSession.swift#L187

Though I guess the proper fix would be to assign "height: 100%" to the first view.

helje5 avatar May 17 '20 15:05 helje5

The HTML body is not yet exposed: https://github.com/SwiftWebUI/SwiftWebUI/blob/develop/Sources/SwiftWebUI/ViewHosting/NIOHostingSession.swift#L187

Though I guess the proper fix would be to assign "height: 100%" to the first view.

What if we could inject CSS rules like:

SwiftWebUI.injectCss(forTag:"body", cssStr: "background-color: black")

vBoykoGit avatar May 26 '20 08:05 vBoykoGit

You could add a static variable to the NIOHostingSession, like

static var extraBodyTagString = ""

and just embed that into the <body \(extraBodyTagString)> tag generation. I think I would be OK w/ a PR which does that.

helje5 avatar May 26 '20 12:05 helje5

You can try set view body the height for 100%, because you page in the content the height Not high enough. So, it Can't fill the entire page. in css, page the height is am content Decide, content the height decide the page the height. If you want page the background all is black, please set html and body element the height for 100% or 100vh. I did not use SwiftUI, but I am a web front-end development engineer. So, Knowledge of css I know a little bit. You can try, hope my advice can help you.

Assone avatar Jul 27 '20 17:07 Assone