forked from toshiaki-h/split_view
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added transition sample for issue toshiaki-h#19.
- Loading branch information
1 parent
ec932f1
commit 341e9fc
Showing
3 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:split_view/split_view.dart'; | ||
|
||
void main() => runApp(MyApp()); | ||
|
||
class MyApp extends StatelessWidget { | ||
// This widget is the root of your application. | ||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
title: 'Flutter Demo', | ||
theme: ThemeData( | ||
primarySwatch: Colors.blue, | ||
), | ||
home: MyHomePage(title: 'Flutter Demo Home Page'), | ||
); | ||
} | ||
} | ||
|
||
class MyHomePage extends StatefulWidget { | ||
MyHomePage({Key? key, this.title}) : super(key: key); | ||
|
||
final String? title; | ||
|
||
@override | ||
_MyHomePageState createState() => _MyHomePageState(); | ||
} | ||
|
||
class _MyHomePageState extends State<MyHomePage> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text(widget.title!), | ||
), | ||
body: SplitView( | ||
children: [ | ||
SplitView( | ||
viewMode: SplitViewMode.Horizontal, | ||
indicator: SplitIndicator(viewMode: SplitViewMode.Horizontal), | ||
activeIndicator: SplitIndicator( | ||
viewMode: SplitViewMode.Horizontal, | ||
isActive: true, | ||
), | ||
gripColorActive: Colors.red, | ||
children: [ | ||
Container( | ||
child: Center(child: Text("View1")), | ||
color: Colors.red, | ||
), | ||
Container( | ||
child: Center(child: Text("View2")), | ||
color: Colors.blue, | ||
), | ||
Container( | ||
child: Center(child: Text("View3")), | ||
color: Colors.green, | ||
), | ||
], | ||
onWeightChanged: (w) => print("Horizon: $w"), | ||
), | ||
Container( | ||
child: Center( | ||
child: ElevatedButton( | ||
child: Text('View4'), | ||
onPressed: () { | ||
Navigator.push(context, MaterialPageRoute( | ||
builder: (context) { | ||
return DummyPage(); | ||
}, | ||
)); | ||
}, | ||
), | ||
), | ||
color: Colors.purple, | ||
), | ||
Container( | ||
child: Center(child: Text("View5")), | ||
color: Colors.yellow, | ||
), | ||
], | ||
viewMode: SplitViewMode.Vertical, | ||
indicator: SplitIndicator(viewMode: SplitViewMode.Vertical), | ||
activeIndicator: SplitIndicator( | ||
viewMode: SplitViewMode.Vertical, | ||
isActive: true, | ||
), | ||
controller: SplitViewController(limits: [null, WeightLimit(max: 0.5)]), | ||
onWeightChanged: (w) => print("Vertical $w"), | ||
), | ||
); | ||
} | ||
} | ||
|
||
class DummyPage extends StatefulWidget { | ||
@override | ||
State<StatefulWidget> createState() => DummyPageState(); | ||
} | ||
|
||
class DummyPageState extends State<DummyPage> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar(title: Text('Dummy')), | ||
body: Center( | ||
child: Text('dummy'), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters