private IPromise <object> showTextDialog() { return(DialogUtils.showDialog( context: context, builder: (context) => { TextEditingController textEditingController = new TextEditingController(); return new SimpleDialog( title: new Text("编辑文本内容"), children: new List <Widget> { new TextField( textInputAction: Unity.UIWidgets.service.TextInputAction.go, controller: textEditingController ), new Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: new List <Widget> { new FlatButton( child: new Text("取消"), onPressed: () => { Navigator.of(context).pop(null); } ), new FlatButton( child: new Text("确定"), onPressed: () => { Navigator.of(context).pop(textEditingController.text); } ) } ) }); })); }
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") ) } )); } ); }
void ShowDiscardDialog(BuildContext context) { DialogUtils.showDialog( context, builder: buildContext => new AlertDialog( shape: new RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(10.0f)) ), title: new Text( L.of(context).DiscardChanges, style: Theme.of(context).textTheme.title ), content: new Text( L.of(context).DiscardChangesContent, style: Theme.of(context).textTheme.body2 ), actions: new List <Widget>() { new FlatButton( child: new Text( L.of(context).Yes, style: Theme.of(context) .textTheme .title .copyWith(color: Colors.purple) ), onPressed: () => { Navigator.pop(buildContext); Navigator.pop(buildContext); } ), new FlatButton( child: new Text( L.of(context).No, style: Theme.of(context) .textTheme .title .copyWith(color: Colors.purple) ), onPressed: () => { Navigator.pop(buildContext); } ) } ) ); }
private IPromise <object> showSelectDialog() { return(DialogUtils.showDialog( context: context, builder: (context) => { TextEditingController textEditingController = new TextEditingController(); return new SimpleDialog( title: new Text("选择来源"), children: new List <Widget> { new SimpleDialogOption( child: new Text("打开相机"), onPressed: () => { Navigator.of(context).pop(false); } ), new SimpleDialogOption( child: new Text("从相册中选择"), onPressed: () => { Navigator.of(context).pop(true); } ), }); })); }
public static Widget SettingBlockColorPicker( BuildContext context, string title, ValueChanged <Color> onColorChanged, Color color = null, string buttonName = "", List <Color> availableColors = null ) { if (color == null) { color = Colors.blueAccent; } if (buttonName == "") { buttonName = color.ToHexString(false); } if (availableColors == null) { availableColors = Utils._defaultColors; } return(new Container( padding: EdgeInsets.symmetric(horizontal: 6f), child: new Row( children: new List <Widget> { new Container(child: new Text(title)), new Expanded( child: new Container( padding: EdgeInsets.all(6), alignment: Alignment.bottomRight, child: new RaisedButton( color: color, child: new Text( buttonName, style: new TextStyle( color: Utils.useWhiteForeground(color) ? Colors.white : Colors.black ) //TextStyle ), //Text onPressed: () => { DialogUtils.showDialog( context: context, builder: (BuildContext _) => { return new AlertDialog( title: new Text("Select color"), content: new SingleChildScrollView( child: new BlockPicker( pickerColor: color, onColorChanged: onColorChanged, availableColors: availableColors ) //BlockPicker ) //SingleChildScrollView ); //AlertDialog } ); //showDialog } ) ) //container ), //expanded } //list ) //row )); }
public static Widget SettingHSVColorPicker( BuildContext context, string title, ValueChanged <Color> onColorChanged, Color color = null, string buttonName = "", bool enableAlpha = false, bool showPreviousColor = false ) { if (color == null) { color = Colors.blueAccent; } if (buttonName == "") { buttonName = color.ToHexString(enableAlpha); } return(new Container( padding: EdgeInsets.symmetric(horizontal: 6f), child: new Row( children: new List <Widget> { new Container(child: new Text(title)), new Expanded( child: new Container( padding: EdgeInsets.all(6), alignment: Alignment.bottomRight, child: new RaisedButton( color: color, child: new Text( buttonName, style: new TextStyle( color: Utils.useWhiteForeground(color) ? Colors.white : Colors.black ) //TextStyle ), //Text onPressed: () => { DialogUtils.showDialog( context: context, builder: (BuildContext _) => { if (showPreviousColor) { return new AlertDialog( titlePadding: EdgeInsets.all(0), contentPadding: EdgeInsets.all(0f), shape: new RoundedRectangleBorder( borderRadius: BorderRadius.circular(25) ), //RoundedRectangleBorder content: new SingleChildScrollView( child: new SlidePicker( pickerColor: color, onColorChanged: onColorChanged, paletteType: PaletteType.hsv, enableAlpha: enableAlpha, displayThumbColor: true, showLabel: false, showIndicator: true, indicatorBorderRadius: BorderRadius.vertical(top: Radius.circular(25)) ) //SlidePicker ) //SingleChildScrollView ); //AlertDialog } else { return new AlertDialog( titlePadding: EdgeInsets.all(0f), contentPadding: EdgeInsets.all(0f), content: new SingleChildScrollView( child: new ColorPicker( pickerColor: color, onColorChanged: onColorChanged, colorPickerWidth: 300f, pickerAreaHeightPercent: 0.7f, enableAlpha: enableAlpha, displayThumbColor: true, showLabel: true, paletteType: PaletteType.hsv, pickerAreaBorderRadius: BorderRadius.only( topLeft: Radius.circular(2f), topRight: Radius.circular(2f) ) //BorderRadius ) //ColorPicker ) //SingleChildScrollView ); //AlertDialog } } ); } ) ) //container ), //expanded } //list ) //row )); }
public override Widget build(BuildContext context) { return(new Theme( data: lightTheme?ThemeData.light() : ThemeData.dark(), child: new DefaultTabController( length: 3, child: new Scaffold( appBar: new AppBar( title: new GestureDetector( child: new Text("Color Picker Example"), onDoubleTap: (DoubleTapDetails details) => setState(() => lightTheme = !lightTheme) ),//GestureDetector bottom: new TabBar( tabs: new List <Widget> { new Tab(text: "HSV"), new Tab(text: "Material"), new Tab(text: "Block") } ) //TabBar ), //AppBar body: new TabBarView( physics: new NeverScrollableScrollPhysics(), children: new List <Widget> { new Column( mainAxisAlignment: MainAxisAlignment.center, children: new List <Widget> { new RaisedButton( elevation: 3f, onPressed: () => { DialogUtils.showDialog( context: context, builder: (BuildContext _) => { return new AlertDialog( titlePadding: EdgeInsets.all(0f), contentPadding: EdgeInsets.all(0f), content: new SingleChildScrollView( child: new ColorPicker( pickerColor: currentColor, onColorChanged: changeColor, colorPickerWidth: 300f, pickerAreaHeightPercent: 0.7f, enableAlpha: true, displayThumbColor: true, showLabel: true, paletteType: PaletteType.hsv, pickerAreaBorderRadius: BorderRadius.only( topLeft: Radius.circular(2f), topRight: Radius.circular(2f) ) //BorderRadius ) //ColorPicker ) //SingleChildScrollView ); //AlertDialog } ); }, child: new Text("Change me"), color: currentColor, textColor: Utils.useWhiteForeground(currentColor) ? new Color(0xffffffff) : new Color(0xff000000) ), //RaisedButton new RaisedButton( elevation: 3f, onPressed: () => { DialogUtils.showDialog( context: context, builder: (BuildContext _) => { return new AlertDialog( titlePadding: EdgeInsets.all(0), contentPadding: EdgeInsets.all(0f), shape: new RoundedRectangleBorder( borderRadius: BorderRadius.circular(25) ), //RoundedRectangleBorder content: new SingleChildScrollView( child: new SlidePicker( pickerColor: currentColor, onColorChanged: changeColor, paletteType: PaletteType.rgb, enableAlpha: false, displayThumbColor: true, showLabel: false, showIndicator: true, indicatorBorderRadius: BorderRadius.vertical(top: Radius.circular(25)) ) //SlidePicker ) //SingleChildScrollView ); //AlertDialog } ); }, child: new Text("Change me again"), color: currentColor, textColor: Utils.useWhiteForeground(currentColor) ? new Color(0xffffffff) : new Color(0xff000000) ) } ), //Column new Center( child: new RaisedButton( elevation: 3f, onPressed: () => { DialogUtils.showDialog( context: context, builder: (BuildContext _) => { return new AlertDialog( titlePadding: EdgeInsets.all(0f), contentPadding: EdgeInsets.all(0f), content: new SingleChildScrollView( child: new MaterialPicker( pickerColor: currentColor, onColorChanged: changeColor, enableLabel: true ) //MaterialPicker ) //SingleChildScrollView ); //AlertDialog } ); //showDialog }, //onPresed child: new Text("Change me"), color: currentColor, textColor: Utils.useWhiteForeground(currentColor) ? new Color(0xffffffff) : new Color(0xff000000) ) //RaisedButton ), //Center new Center( child: new Column( mainAxisAlignment: MainAxisAlignment.center, children: new List <Widget> { new RaisedButton( elevation: 3f, onPressed: () => { DialogUtils.showDialog( context: context, builder: (BuildContext _) => { return new AlertDialog( title: new Text("Select color"), content: new SingleChildScrollView( child: new BlockPicker( pickerColor: currentColor, onColorChanged: changeColor ) //BlockPicker ) //SingleChildScrollView ); //AlertDialog } ); //showDialog }, //onPressed child: new Text("Change me again"), color: currentColor, textColor: Utils.useWhiteForeground(currentColor) ? new Color(0xffffffff) : new Color(0xff000000) ) //RaisedButton } ) //Column ) //center } ) //TabBarView ) //Scaffold ) //DefaultTabController )); //Theme }//function build
public override Widget build(BuildContext context) { return(new StoreConnector <AppState, AppState>( converter: state => state, builder: (buildContext, model, dispatcher) => { return new Scaffold( appBar: new AppBar( elevation: 0, title: new Text( widget.Mode == NoteEditorMode.CREATION ? L.of(context).AddNote : L.of(context).EditNote, style: Theme.of(context).textTheme.headline), backgroundColor: AppConst.Colors[mColorIndex], leading: new IconButton( icon: new Icon(Icons.arrow_back_ios, color: Colors.black), onPressed: () => { if (widget.Mode == NoteEditorMode.MODIFICATION && SaveBtnVisible) { ShowDiscardDialog(context); } else { Navigator.of(context).pop(); } } ), actions: new List <Widget>() { SaveBtnVisible ? new IconButton( icon: new Icon(Icons.save, color: Colors.black), onPressed: () => { widget.Note.Title = mTitleController.text; widget.Note.Description = mDescriptionController.text; widget.Note.Priority = mPriorityIndex; widget.Note.ColorIndex = mColorIndex; widget.Note.NotebookId = mNotebookId; if (widget.Mode == NoteEditorMode.CREATION) { dispatcher.dispatch(new AddNoteAction(widget.Note)); } else { dispatcher.dispatch(new UpdateNoteAction(widget.Note)); } Navigator.pop(context); } ) : new Container() as Widget, widget.Mode == NoteEditorMode.MODIFICATION ? new IconButton( icon: new Icon(Icons.delete, color: Colors.black), onPressed: () => { ShowDeleteDialog(context, () => { dispatcher.dispatch(new DeleteNoteAction(widget.Note)); Navigator.of(context).pop(); }); } ) as Widget : new Container() } ), body: new Container( color: AppConst.Colors[mColorIndex], child: new Column( children: new List <Widget>() { new PriorityPicker( mPriorityIndex, priorityIndex => { setState(() => { mPriorityIndex = priorityIndex; }); } ), new ColorPicker(mColorIndex, colorIndex => { setState(() => { mColorIndex = colorIndex; }); }), new Padding( padding: EdgeInsets.all(16), child: new TextField( controller: mTitleController, onChanged: value => { this.setState(() => { }); }, style: Theme.of(context).textTheme.title, decoration: new InputDecoration( hintText: L.of(context).Title ) ) ), new Expanded( child: new Padding( padding: EdgeInsets.all(16), child: new Column( children: new List <Widget>() { new TextField( controller: mDescriptionController, onChanged: value => { this.setState(() => { }); }, style: Theme.of(context).textTheme.subhead, keyboardType: TextInputType.multiline, maxLength: 255, maxLines: 10, decoration: new InputDecoration( hintText: L.of(context).Description ) ), new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: new List <Widget> { new OutlineButton( child: new Text( Utils.GetNotebookName(model.Notebooks, mNotebookId, L.of(context).SelectNotebook), style: Theme.of(context).textTheme.subhead), onPressed: () => { DialogUtils.showDialog(context, builder: context1 => new NotebookPicker(mNotebookId, selectedId => { mNotebookId = selectedId; setState(() => { }); })); } ), new OutlineButton( child: new Text(L.of(context).MarkdownPreview, style: Theme.of(context).textTheme.subhead), onPressed: () => { Navigator.of(context) .push(new MaterialPageRoute( builder: context1 => new MarkdownPreviewer(mColorIndex, mTitleController.text, mDescriptionController.text))); } ) } ), } ) ) ) } ) ) ); } )); }