-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add background modifier #734
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something is definitely weird with how the background/foreground modifiers are interacting, though it's not obvious to me what the issue is.
In plain old SwiftUI, the following (translated directly from your example) results in just a red circle appearing, since the foreground style is applying to both the Circle and the Image.
Image(systemName: "heart.fill")
.background(alignment: .center) {
Circle()
.frame(width: 32, height: 32)
}
.foregroundStyle(.red)
To get the result that you actually show, you'd need to move the foreground style inside the background modifier so that it only applies to the Circle:
Image(systemName: "heart.fill")
.background(alignment: .center) {
Circle()
.frame(width: 32, height: 32)
.foregroundStyle(.red)
}
Image(systemName: "heart.fill")
.foregroundColor(nil)
.background(alignment: .center) {
Circle()
.frame(width: 32, height: 32)
}
.foregroundStyle(.red)
The attribute should probably be removed from Text has the same problem. The |
RE the |
Ah, that is indeed the case. We do probably want general modifiers for them, but I think the I think a workaround would be having helpers like |
841402f
to
b665ff1
Compare
53d795b
to
406f680
Compare
@shadowfacts I added |
@supernintendo I think liveview-client-swiftui/Sources/LiveViewNative/Views/Text Input and Output/Text.swift Lines 75 to 79 in f420c8e
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, just needs a slight tweak to make the docs visible
Sources/LiveViewNative/Modifiers/Layout Fundamentals Modifiers/BackgroundModifier.swift
Show resolved
Hide resolved
f7e7172
to
edf9270
Compare
edf9270
to
a283c18
Compare
Adds support for the background modifier and adds the ability to use namespaced child elements when decoding modifiers. This is based on @carson-katri's idea for handling nested views within modifiers via Content Entities as described here.
There are a few outstanding issues with this PR:
The
foreground_style
modifier influences the background content instead of thebackground_style
modifier which doesn't appear to do anything. I'm not sure why this is but from what I can tell the native backgroundStyle modifier only affects nested content rendered using thein:
constructor and not content passed tocontent
.There seem to be performance limitations with nested modifier views in my implementation. By rendering too many elements with background modifiers within the same view I'm able to produce a crash, although I haven't investigated this enough to know what might be causing it.
The string format forFixed in 2ccb51econtent
when referencing namespaced child views could be a bit confusing. I'd like to tweak the Elixir modifier schema so that it accepts an atom instead, which should ameliorate this.Closes #183.