Closed lrmoorejr closed 2 years ago
Hi @lrmoorejr ! Thanks.
Sorry if I didn't understand the question/problem correctly.
The simplest way to animate the dividers is just to define the colors (color
and highlightedColor
). The animationEnabled
parameter (true
by default), will animate the color between color
and highlightedColor
:
MultiSplitViewTheme theme = MultiSplitViewTheme(
data: MultiSplitViewThemeData(
dividerPainter: DividerPainters.grooved2(
color: Colors.blue.withAlpha(0),
highlightedColor: Colors.blue)),
child: multiSplitView);
This will animate the dividers when the mouse is over them.
But if you're trying to animate without the mouse over, try to disable de animation with animationEnabled = false
.
I changed the example to be as close as possible to the code you put in and apparently it worked by starting the animation on the click of buttons:
import 'package:flutter/material.dart';
import 'package:multi_split_view/multi_split_view.dart';
void main() => runApp(MultiSplitViewExampleApp());
class MultiSplitViewExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MultiSplitViewExample(),
);
}
}
class MultiSplitViewExample extends StatefulWidget {
final List<Color> _colors = [Colors.red, Colors.blue, Colors.green];
@override
_MultiSplitViewExampleState createState() => _MultiSplitViewExampleState();
}
class _MultiSplitViewExampleState extends State<MultiSplitViewExample>
with TickerProviderStateMixin {
late AnimationController _controller;
late Animation _animationCurve;
@override
void initState() {
super.initState();
_controller = new AnimationController(
duration: new Duration(milliseconds: 3000), vsync: this)
..addListener(() {
print('value ' + _animationCurve.value.toString());
//setState(() {});
});
_animationCurve = new Tween(
begin: 0.5,
end: 1.0,
).animate(
new CurvedAnimation(parent: _controller, curve: Curves.bounceOut));
}
@override
Widget build(BuildContext context) {
Widget buttons = Container(
child: Row(children: [
ElevatedButton(
child: Text('Forward'), onPressed: _onForwardButtonClick),
SizedBox(width: 16),
ElevatedButton(
child: Text('Reverse'), onPressed: _onReverseButtonClick)
], crossAxisAlignment: CrossAxisAlignment.center),
color: Colors.white,
padding: EdgeInsets.all(8));
List<Widget> children = List.empty(growable: true);
for (int i = 0; i < 3; i++) {
Widget view = Container(
child: Center(child: Text("View " + (i + 1).toString())),
color: widget._colors[i % widget._colors.length],
);
children.add(view);
}
MultiSplitView multiSplitView = MultiSplitView(
children: children,
controller: MultiSplitViewController(initialWeights: [.05, .1, .6]));
AnimatedBuilder animatedBuilder = AnimatedBuilder(
animation: _animationCurve,
builder: (context, widget) {
return MultiSplitViewTheme(
data: MultiSplitViewThemeData(
dividerPainter: DividerPainters.grooved2(
animationEnabled: false,
color: Colors.blue
.withAlpha((_animationCurve.value * 255).round()),
highlightedColor: Colors.red)),
child: multiSplitView);
});
return Scaffold(
appBar: AppBar(title: Text('Multi Split View Example')),
body: Column(children: [buttons, Expanded(child: animatedBuilder)])
// body: horizontal,
);
}
_onReverseButtonClick() {
_controller.reverse();
}
_onForwardButtonClick() {
_controller.forward();
}
}
Was I helpful? Hope so.
Hi Carlos!
I’m sorry— I think I was overly concise.
The built-in mouse-over animation works great— no problems there. I am trying to add an animation when the page loads, too, where the divider fades in to “color” and then thereafter the mouseover transitions it to “highlight color.”
One option might be to wrap the MultiSplitViewTheme in an Opacity widget. Unfortunately, I only want the divider to fade in, not the child panels. (The child panels will be sliding in from off screen.). So, wrapping in an Opacity won’t work for me.
It seems like I should be able to animate the DividerPainter's color: property during page load to achieve this effect, but it stays transparent instead of transitioning to an opaque color as the page loads. It is as if a static variable is being set somewhere and never updated again.
I tried setting animationEnabled: to false during the page load, and that does allow the dividers to fade in. Unfortunately, after the page loads and animationEnabled: is set to true, the mouseover animation is not enabled.
Based on your example, I could probably acheive what I’m looking for with two nested AnimationBuilders. One animationBuilder would fade the divider in during page load, and the other would transition the color during a mouseover. The problem with this, though, is that I don’t want to rebuild the child panels every time someone mouse-overs the divider. It’s much better to use your built-in animation for the mouseovers.
If this isn’t clear, I can send a complete example. Thanks again for your help— I really appreciate it.
Rick
On Oct 31, 2021, at 8:02 PM, Carlos Eduardo Leite de Andrade @.***> wrote:
Hi @lrmoorejr https://github.com/lrmoorejr ! Thanks.
Sorry if I didn't understand the question/problem correctly.
The simplest way to animate the dividers is just to define the colors (color and highlightedColor). The animationEnabled parameter (true by default), will animate the color between color and highlightedColor:
MultiSplitViewTheme theme = MultiSplitViewTheme( data: MultiSplitViewThemeData( dividerPainter: DividerPainters.grooved2( color: Colors.blue.withAlpha(0), highlightedColor: Colors.blue)), child: multiSplitView);
This will animate the dividers when the mouse is over them.
But if you're trying to animate without the mouse over, try to disable de animation with animationEnabled = false.
I changed the example to be as close as possible to the code you put in and apparently it worked by starting the animation on the click of buttons:
import 'package:flutter/material.dart'; import 'package:multi_split_view/multi_split_view.dart';
void main() => runApp(MultiSplitViewExampleApp());
class MultiSplitViewExampleApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.blue, ), home: MultiSplitViewExample(), ); } }
class MultiSplitViewExample extends StatefulWidget { final List
_colors = [Colors.red, Colors.blue, Colors.green]; @override _MultiSplitViewExampleState createState() => _MultiSplitViewExampleState(); }
class _MultiSplitViewExampleState extends State
with TickerProviderStateMixin { late AnimationController _controller; late Animation _animationCurve; @override void initState() { super.initState(); _controller = new AnimationController( duration: new Duration(milliseconds: 3000), vsync: this) ..addListener(() { print('value ' + _animationCurve.value.toString()); //setState(() {}); }); _animationCurve = new Tween( begin: 0.5, end: 1.0, ).animate( new CurvedAnimation(parent: _controller, curve: Curves.bounceOut)); }
@override Widget build(BuildContext context) { Widget buttons = Container( child: Row(children: [ ElevatedButton( child: Text('Forward'), onPressed: _onForwardButtonClick), SizedBox(width: 16), ElevatedButton( child: Text('Reverse'), onPressed: _onReverseButtonClick) ], crossAxisAlignment: CrossAxisAlignment.center), color: Colors.white, padding: EdgeInsets.all(8));
List<Widget> children = List.empty(growable: true); for (int i = 0; i < 3; i++) { Widget view = Container( child: Center(child: Text("View " + (i + 1).toString())), color: widget._colors[i % widget._colors.length], ); children.add(view); } MultiSplitView multiSplitView = MultiSplitView( children: children, controller: MultiSplitViewController(initialWeights: [.05, .1, .6])); AnimatedBuilder animatedBuilder = AnimatedBuilder( animation: _animationCurve, builder: (context, widget) { return MultiSplitViewTheme( data: MultiSplitViewThemeData( dividerPainter: DividerPainters.grooved2( animationEnabled: false, color: Colors.blue .withAlpha((_animationCurve.value * 255).round()), highlightedColor: Colors.red)), child: multiSplitView); }); return Scaffold( appBar: AppBar(title: Text('Multi Split View Example')), body: Column(children: [buttons, Expanded(child: animatedBuilder)]) // body: horizontal, );
}
_onReverseButtonClick() { _controller.reverse(); }
_onForwardButtonClick() { _controller.forward(); } } Was I helpful? Hope so.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/caduandrade/multi_split_view/issues/13#issuecomment-955884410, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMV6FW2IA6XR7RCROVXBEL3UJX7MPANCNFSM5HB2CWPQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You must be doing something really cool and beautiful :wink:
Well, you figure out a bug about the animationEnabled
. I changed my example to use a variable in State
to keep the animation false
. I also put a listener to set the animation to true
after the first status == AnimationStatus.completed
. You are right, no more animation after that. :man_facepalming:
I will try to fix it. Maybe it's will be enough for you right?
Thanks; I wish I could share but it’s a little early to post a link on the web.
Yep, that fix would be enough, thank you! I suspect when you figure out why the animationEnabled: doesn’t get updated, you’ll realize why the color: isn’t getting updated. Probably the same issue. But, again, fixing the animationEnabled is enough for me.
Thanks, Rick
On Nov 1, 2021, at 1:02 PM, Carlos Eduardo Leite de Andrade @.***> wrote:
You must be doing something really cool and beautiful 😉
Well, you figure out a bug about the animationEnabled. I changed my example to use a variable in State to keep the animation false. I also put a listener to set the animation to true after the first status == AnimationStatus.completed. You are right, no more animation after that. 🤦♂️
I will try to fix it. Maybe it's will be enough for you right?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/caduandrade/multi_split_view/issues/13#issuecomment-956546030, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMV6FW7H7H6G5IIQQHRLZVLUJ3W5LANCNFSM5HB2CWPQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
This issue can be solved by #14
Hi @lrmoorejr!
Can I ask you a favor? I committed the #14. So, could you clone this project and test your code using the relative path in the dependency? If it works, I can release it.
Seems like the least I could do for your help. :)
Yep, it works! I don’t even need to toggle animationEnabled: and it fades in smoothly and still animates with a mouseover. Well done!
Rick
On Nov 1, 2021, at 2:24 PM, Carlos Eduardo Leite de Andrade @.***> wrote:
Hi @lrmoorejr https://github.com/lrmoorejr!
Can I ask you a favor? I committed the #14 https://github.com/caduandrade/multi_split_view/issues/14. So, could you clone this project and test your code using the relative path in the dependency? If it works, I can release it.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/caduandrade/multi_split_view/issues/13#issuecomment-956625104, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMV6FWZTAUYWQOK4GTSH5X3UJ4AQHANCNFSM5HB2CWPQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Excellent! Mission Accomplished :wink: I released version 1.9.1. I'm closing this issue ok? Nice to meet you and good luck with your project!
Sounds great, thanks again for all your help!
Rick
On Nov 1, 2021, at 3:36 PM, Carlos Eduardo Leite de Andrade @.***> wrote:
Excellent! Mission Accomplished 😉 I released version 1.9.1. I'm closing this issue ok? Nice to meet you and good luck with your project!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/caduandrade/multi_split_view/issues/13#issuecomment-956775388, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMV6FW7KCYIAR5A4MSLZXTLUJ4JALANCNFSM5HB2CWPQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Hello! This is a great widget, thanks for sharing it. I've noticed one little thing, though:
I'm trying to animate a fade in of the divider like this:
I've confirmed that the the color values are getting animated correctly, and it winds up with 0xffd0d0d0 after the animation is complete, but the divider remains completely transparent on screen, even when I force refreshes.