Comments (5)
Indeed, this does sound like a good option for people. It was a little hard to find what was actually done amidst all the formatting changes in #23 😜.
FWIW, I made one change to your PR before I did anything, in Split.swift, line 98, adding .height: pHeight
:
.frame(width: pWidth, height: pHeight)
If I run the "Sidebars" SplitDemo with the option enabled:
Split(
isResizing: false,
primary: {
List(leftItems, id: \.self) { item in
Text(item)
.lineLimit(1)
.truncationMode(.tail)
}
.listStyle(.plain)
.padding([.top], 8)
},
secondary: {
Split(
isResizing: false,
primary: {
VStack {
Text(middleText)
.frame(maxWidth: .infinity, alignment: .leading)
Spacer()
}
.padding(8)
},
secondary: {
VStack {
Text(rightText)
.frame(maxWidth: .infinity, alignment: .leading)
Spacer()
}
.padding(8)
}
)
.splitter { Splitter.line() }
.constraints(minPFraction: 0.3, minSFraction: 0.2, priority: .secondary, dragToHideS: true)
.layout(demo.holders[0].layout)
.fraction(0.75)
.hide(demo.holders[0].hide)
}
)
the changes cause the primary sides to not show properly:
I don't really have a good way to test things, frankly, since it's all visual, so I use the DemoApp. The Sidebars demo is sometimes less forgiving than the ones using Colors, but the "Nested adjustable" also has the same problem.
My preference for folding this kind of thing in would be to add it to the .constraints
modifier at the end of the existing options. This way the public initializers for Split, HSplit, and VSplit don't change and it's more consistent with the approach I've taken overall.
from splitview.
Hmm, I'll verify my changes again using provided demo app, before pushing new commits.
I did however change the way this setting is applied — now it's done using .disableResizing()
modifier on the view itself.
from splitview.
FWIW, I made one change to your PR before I did anything, in Split.swift, line 98, adding
.height: pHeight
:.frame(width: pWidth, height: pHeight)
I skipped the height parameter intentionally. I'm using VSplit in my app and I needed the top View to keep its original height no matter what. That's why isResizing
flag is used here, with the .offset
modifier to act like in its original behaviour.
I believe in HSplit, analogically the width should be omitted.
from splitview.
After some testing with DemoApp, I came to conclusion that this behaviour is kinda expected.
If we disable resizing by setting isResizing
flag to false, the view won't be resized to fit it's parent container.
That was the goal for me, because I wanted to have a Map in split view. Resizing it while dragging was causing poor performance.
.disableResizing(true)
therefore works as expected, it just disables the width adjusting in horizontal mode, height in vertical.
However I do see the issue with this modifier, as it produces results that may be not entirely obvious and seem like a bug.
from splitview.
I'm not going to be able to merge a PR that causes such unexpected behavior when applied to something as simple as a space-filling Color.
The Map view seems to scale and resize perfectly fine for me:
struct DemoApp: View {
@State private var demoID: DemoID = .simpleDefaults
@State private var pRegion = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 51.507222, longitude: -0.1275), span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5))
@State private var sRegion = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 37.779379, longitude: -122.418433), span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5))
var body: some View {
let demo = demos[demoID]!
VStack {
DemoToolbar(demoID: $demoID)
switch demoID {
case .simpleDefaults:
HSplit(
left: { Map(coordinateRegion: $pRegion) },
right: { Map(coordinateRegion: $sRegion) }
)
...
If you have an expensive overlay that needs to be recalculated as sizing changes, then perhaps an alternative approach would be to use onDrag
to disable it when dragging starts and then recalculate it when dragging ends (or position a button overlay to optionally recalculate it like the Yelp app does). If needed, you could do an onDragEnd
view modifier that is invoked like onDrag
, but in the .onEnded
closure of Split.drag(in:)
:
.onEnded { gesture in
previousPosition = nil
styling.previewHide = false // We are never previewing the hidden state when drag ends
hide.side = sideToHide()
// The fullFraction is used to determine the sideToHide, so we need to reset when done dragging,
// but *after* setting the hide.side.
fullFraction = constrainedFraction
fraction.value = constrainedFraction
onDragEnd?()
}
from splitview.
Related Issues (20)
- Issue When Dragging a Splitter Outside the Parent Window on MacOS HOT 4
- Instantiating from a simpler format? HOT 1
- Change cursor on Mac when inside splitter HOT 4
- UserDefaults - working ? HOT 6
- Set SplitView Constraints Maximum HOT 1
- Set SplitView Constraints by absolute number HOT 1
- Nested views ad infinitum HOT 3
- Sticky buttons in secondary views or on press repeat HOT 4
- Feature: minimum split size HOT 8
- Bug: splitter line should be invisible when hidden HOT 2
- divider's visual bug HOT 11
- Breakpoints & animations HOT 1
- Hidden view still visible partly HOT 4
- Custom splitter using drag-to-hide
- Setting fraction programmatically (after the split view is shown already) HOT 2
- CustomSplitter disappears when constraints is set HOT 4
- Bug when hiding splitview while using minimum fractions HOT 3
- Default splitter HOT 2
- Fraction animation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from splitview.