浏览代码

Implement persistent bottom sheet demo.

/main
Yuncong Zhang 6 年前
当前提交
9b6f48ae
共有 3 个文件被更改,包括 114 次插入9 次删除
  1. 18
      Samples/UIWidgetsGallery/gallery/demos.cs
  2. 102
      Samples/UIWidgetsGallery/demo/material/persistent_bottom_sheet_demo.cs
  3. 3
      Samples/UIWidgetsGallery/demo/material/persistent_bottom_sheet_demo.cs.meta

18
Samples/UIWidgetsGallery/gallery/demos.cs


documentationUrl: "https://docs.flutter.io/flutter/material/showModalBottomSheet.html",
buildRoute: (BuildContext context) => new ModalBottomSheetDemo()
),
// new GalleryDemo(
// title: "Bottom sheet: Persistent",
// subtitle: "A bottom sheet that sticks around",
// icon: GalleryIcons.bottom_sheet_persistent,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: PersistentBottomSheetDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/ScaffoldState/showBottomSheet.html",
// buildRoute: (BuildContext context) => PersistentBottomSheetDemo()
// ),
new GalleryDemo(
title: "Bottom sheet: Persistent",
subtitle: "A bottom sheet that sticks around",
icon: GalleryIcons.bottom_sheet_persistent,
category: _kMaterialComponents,
routeName: PersistentBottomSheetDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/ScaffoldState/showBottomSheet.html",
buildRoute: (BuildContext context) => new PersistentBottomSheetDemo()
),
new GalleryDemo(
title: "Buttons",
subtitle: "Flat, raised, dropdown, and more",

102
Samples/UIWidgetsGallery/demo/material/persistent_bottom_sheet_demo.cs


using System.Collections.Generic;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using DialogUtils = Unity.UIWidgets.material.DialogUtils;
namespace UIWidgetsGallery.gallery {
public class PersistentBottomSheetDemo : StatefulWidget {
public const string routeName = "/material/persistent-bottom-sheet";
public override State createState() {
return new _PersistentBottomSheetDemoState();
}
}
class _PersistentBottomSheetDemoState : State<PersistentBottomSheetDemo> {
GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>.key();
VoidCallback _showBottomSheetCallback;
public override void initState() {
base.initState();
this._showBottomSheetCallback = this._showBottomSheet;
}
void _showBottomSheet() {
this.setState(() => {
// disable the button
this._showBottomSheetCallback = null;
});
this._scaffoldKey.currentState.showBottomSheet((BuildContext context) => {
ThemeData themeData = Theme.of(this.context);
return new Container(
decoration: new BoxDecoration(
border: new Border(top: new BorderSide(color: themeData.disabledColor))
),
child: new Padding(
padding: EdgeInsets.all(32.0f),
child: new Text("This is a Material persistent bottom sheet. Drag downwards to dismiss it.",
textAlign: TextAlign.center,
style: new TextStyle(
color: themeData.accentColor,
fontSize: 24.0f
)
)
)
);
})
.closed.Then((value) => {
if (this.mounted) {
this.setState(() => {
// re-enable the button
this._showBottomSheetCallback = this._showBottomSheet;
});
}
});
}
void _showMessage() {
DialogUtils.showDialog(
context: this.context,
builder: (BuildContext context) => {
return new AlertDialog(
content: new Text("You tapped the floating action button."),
actions: new List<Widget> {
new FlatButton(
onPressed: () => { Navigator.pop(context); },
child: new Text("OK")
)
}
);
}
);
}
public override Widget build(BuildContext context) {
return new Scaffold(
key: this._scaffoldKey,
appBar: new AppBar(
title: new Text("Persistent bottom sheet"),
actions: new List<Widget> {
new MaterialDemoDocumentationButton(PersistentBottomSheetDemo.routeName)
}
),
floatingActionButton: new FloatingActionButton(
onPressed: this._showMessage,
backgroundColor: Colors.redAccent,
child: new Icon(
Icons.add
)
),
body: new Center(
child: new RaisedButton(
onPressed: this._showBottomSheetCallback,
child: new Text("SHOW BOTTOM SHEET")
)
)
);
}
}
}

3
Samples/UIWidgetsGallery/demo/material/persistent_bottom_sheet_demo.cs.meta


fileFormatVersion: 2
guid: afb410d95c524a18b8761713f1335427
timeCreated: 1555059936
正在加载...
取消
保存