Skip to content

Commit

Permalink
Non-scrollable ResizablePane (#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
stMerlHin authored Jul 12, 2023
1 parent ebcd257 commit de3e35c
Show file tree
Hide file tree
Showing 8 changed files with 330 additions and 49 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [2.0.0-beta.9]
* `ResizablePane` can now disallow the usage of its internal scrollbar via the `ReziablePane.noScrollBar` constructor.

## [2.0.0-beta.8]
✨ New ✨
* `MacosFontWeight` allows using Apple-specific font weights like `w510`, `w590`, and `w860`.
Expand Down
12 changes: 4 additions & 8 deletions example/lib/pages/resizable_pane_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,12 @@ class _ResizablePanePageState extends State<ResizablePanePage> {
);
},
),
ResizablePane(
const ResizablePane.noScrollBar(
minSize: 180,
startSize: 200,
// windowBreakpoint: 800,
resizableSide: ResizableSide.left,
builder: (_, __) {
return const Center(
child: Text('Right Resizable Pane'),
);
},
windowBreakpoint: 700,
resizableSide: ResizableSide.right,
child: Center(child: Text('Right non-scrollable Resizable Pane')),
),
],
);
Expand Down
2 changes: 1 addition & 1 deletion example/lib/widgets/widget_text_title1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ class WidgetTextTitle1 extends StatelessWidget {
),
);
}
}
}
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.0.0-beta.8"
version: "2.0.0-beta.9"
macos_window_utils:
dependency: transitive
description:
Expand Down
62 changes: 54 additions & 8 deletions lib/src/layout/resizable_pane.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,54 @@ enum ResizableSide {
/// The [startSize] is the initial width or height depending on the orientation of the pane.
/// {@endtemplate}
class ResizablePane extends StatefulWidget {
/// {@macro resizablePane}
/// Creates a [ResizablePane] with an internal [MacosScrollbar].
///
/// Consider using [ResizablePane.noScrollBar] constructor when the internal
/// [MacosScrollbar] is not needed or when working with widgets which do not
/// expose their scroll controllers.
/// {@macro resizablePane}.
const ResizablePane({
super.key,
required this.builder,
required ScrollableWidgetBuilder this.builder,
this.decoration,
this.maxSize = 500.0,
required this.minSize,
this.isResizable = true,
required this.resizableSide,
this.windowBreakpoint,
required this.startSize,
}) : assert(
}) : child = null,
useScrollBar = true,
assert(
maxSize >= minSize,
'minSize should not be more than maxSize.',
),
assert(
(startSize >= minSize) && (startSize <= maxSize),
'startSize must not be less than minSize or more than maxWidth',
);

/// Creates a [ResizablePane] without an internal [MacosScrollbar].
///
/// Useful when working with widgets which do not expose their scroll
/// controllers or when not using the platform scroll bar is preferred.
///
/// Consider using the default constructor if showing a [MacosScrollbar]
/// when scrolling the content of this widget is the expected behavior.
/// {@macro resizablePane}.
const ResizablePane.noScrollBar({
super.key,
required Widget this.child,
this.decoration,
this.maxSize = 500.0,
required this.minSize,
this.isResizable = true,
required this.resizableSide,
this.windowBreakpoint,
required this.startSize,
}) : builder = null,
useScrollBar = false,
assert(
maxSize >= minSize,
'minSize should not be more than maxSize.',
),
Expand All @@ -55,7 +91,15 @@ class ResizablePane extends StatefulWidget {
///
/// Pass the [scrollController] obtained from this method, to a scrollable
/// widget used in this method to work with the internal [MacosScrollbar].
final ScrollableWidgetBuilder builder;
final ScrollableWidgetBuilder? builder;

/// The child to display in this widget.
///
/// This is only referenced when the constructor used is [ResizablePane.noScrollbar].
final Widget? child;

/// Specify if this [ResizablePane] should have an internal [MacosScrollbar].
final bool useScrollBar;

/// The [BoxDecoration] to paint behind the child in the [builder].
final BoxDecoration? decoration;
Expand Down Expand Up @@ -277,10 +321,12 @@ class _ResizablePaneState extends State<ResizablePane> {
SafeArea(
left: false,
right: false,
child: MacosScrollbar(
controller: _scrollController,
child: widget.builder(context, _scrollController),
),
child: widget.useScrollBar
? MacosScrollbar(
controller: _scrollController,
child: widget.builder!(context, _scrollController),
)
: widget.child!,
),
if (widget.isResizable && !_resizeOnRight && !_resizeOnTop)
Positioned(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: macos_ui
description: Flutter widgets and themes implementing the current macOS design language.
version: 2.0.0-beta.8
version: 2.0.0-beta.9
homepage: "https://macosui.dev"
repository: "https://github.com/GroovinChip/macos_ui"

Expand Down
Loading

0 comments on commit de3e35c

Please sign in to comment.