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); } ) } ) }); })); }
public override Widget build(BuildContext context) { return(new Scaffold( appBar: new AppBar( title: new Text("Retrieve Text Input") ), body: new Padding( padding: EdgeInsets.all(16.0f), child: new TextField( controller: this.myController, autofocus: true, decoration: new InputDecoration( hintText: "hinthere", labelText: "pwd", prefixIcon: new Icon(Unity.UIWidgets.material.Icons.search))) ), floatingActionButton: new FloatingActionButton( // When the user presses the button, show an alert dialog with the // text the user has typed into our text field. onPressed: () => { DialogUtils.showDialog( context: context, builder: (_context) => { return new AlertDialog( // Retrieve the text the user has typed in using our // TextEditingController content: new Text(this.myController.text) ); }); }, tooltip: "Show me the value", child: new Icon(Icons.search) ) )); }
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); } ) } ) ); }
public static IPromise <object> showDatePicker( BuildContext context, DateTime initialDate, DateTime firstDate, DateTime lastDate, SelectableDayPredicate selectableDayPredicate = null, DatePickerMode initialDatePickerMode = DatePickerMode.day, Locale locale = null, TransitionBuilder builder = null ) { D.assert(initialDate >= firstDate, () => "initialDate must be on or after firstDate"); D.assert(initialDate <= lastDate, () => "initialDate must be on or before lastDate"); D.assert(firstDate <= lastDate, () => "lastDate must be on or after firstDate"); D.assert( selectableDayPredicate == null || selectableDayPredicate(initialDate), () => "Provided initialDate must satisfy provided selectableDayPredicate" ); D.assert(context != null); D.assert(MaterialD.debugCheckHasMaterialLocalizations(context)); Widget child = new _DatePickerDialog( initialDate: initialDate, firstDate: firstDate, lastDate: lastDate, selectableDayPredicate: selectableDayPredicate, initialDatePickerMode: initialDatePickerMode ); if (locale != null) { child = Localizations.overrides( context: context, locale: locale, child: child ); } return(DialogUtils.showDialog( context: context, builder: (BuildContext _context) => { return builder == null ? child : builder(_context, child); } )); }
public override Widget build(BuildContext context) { var size = MediaQuery.of(context).size; var screenWidth = size.width * 0.8f; return(new Game( child: new KeyboardController( child: SizedBox.expand( child: new Container( color: AppConstants.APP_BACKGROUND_COLOR, child: new Padding( padding: MediaQuery.of(context).padding, child: new Column( children: new List <Widget> { new Row( children: new List <Widget>() { new Spacer(), new FlatButton( onPressed: () => { DialogUtils.showDialog(context, builder: ctx => new DonationDialog()); }, child: new Text(L.of(context).Reward) ) } ), new Spacer(), new ScreenDecoration(child: new GBScreen(width: screenWidth)), new Spacer(flex: 2), new GBJoyStick() } ) ) ) ) ) )); }
List <Widget> BuildNotebooks(List <Notebook> notebooks, Dispatcher dispatcher, BuildContext context) { var retList = new List <Widget>() { new ListTile( leading: new Icon(Icons.add, color: Colors.black), title: new Text(L.of(context).CreateNotebook, style: Theme.of(context).textTheme.subhead .copyWith(fontWeight: FontWeight.bold)), onTap: () => { DialogUtils.showDialog(context, builder: context1 => new NotebookEditor(dispatcher)); } ) }; retList.AddRange(notebooks.Select(notebook => new ListTile( leading: new Icon(Icons.bookmark, color: Colors.black), title: new Text(notebook.Name, style: Theme.of(context).textTheme.subhead.copyWith(fontWeight: FontWeight.bold)), trailing: new IconButton( icon: new Icon(Icons.edit, color: Colors.black), onPressed: () => { DialogUtils.showDialog(context, builder: buildContext => new NotebookEditor(dispatcher, NotebookEditorMode.MODIFICATION, notebook)); } ), onTap: () => { dispatcher.dispatch( new ApplyFilterAction(Filter.ByNotebook(context, notebook.Id, notebook.Name))); Navigator.of(context).pop(); } ) )); return(retList); }
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 override Widget build(BuildContext context) { return(new SimpleDialog( contentPadding: EdgeInsets.only(left: 8, top: 8, right: 8, bottom: 4), children: new List <Widget>() { new SizedBox(width: MediaQuery.of(context).size.width), new Container(padding: EdgeInsets.all(8), child: new Text("开发不易,捐助一下给开发者。")), new ActionTile("微信捐赠", () => { DialogUtils.showDialog(context: context, builder: ctx => ReceiptDialog.Wechat()) .Then(_ => { Navigator.pop(context); }); }), new ActionTile("支付宝捐赠", () => { DialogUtils.showDialog(context: context, builder: ctx => ReceiptDialog.Alipay()) .Then(_ => { Navigator.pop(context); }); }) } )); }
public override Widget build(BuildContext context) { return(new StoreConnector <AppState, AppState>( converter: state => state, builder: (buildContext, model, dispatcher) => { return new Scaffold( appBar: new AppBar( centerTitle: true, elevation: 0, leading: new IconButton( icon: new Icon(Icons.arrow_back), onPressed: () => { Navigator.pop(context); } ), title: new Text(widget.CreateMode ? "New Habit" : "Edit Habit"), bottom: new PreferredSize( preferredSize: Size.fromHeight(1), child: new Container( height: 0.5f, color: Colors.white30 ) ), actions: new List <Widget>() { new FlatButton( child: new Text(widget.CreateMode ? "" : "Delete", style: new TextStyle(color: Colors.red)), onPressed: () => { DialogUtils.showDialog( context: context, builder: (context1 => { return new Theme( data: new ThemeData(dialogBackgroundColor: new Color(0xFF333333)), child: new AlertDialog( contentPadding: EdgeInsets.fromLTRB(24, 24, 24, 0), content: new Text("Really want to delete this habit?", style: new TextStyle(color: Colors.white70) ), actions: new List <Widget>() { new FlatButton( child: new Text("Yes", style: new TextStyle(color: Colors.red) ), onPressed: () => { dispatcher.dispatch( new DeleteHabitAction(widget.Habit)); Navigator.pop(context1); Navigator.pop(context); }), new FlatButton( child: new Text("No", style: new TextStyle(color: Colors.white70) ), onPressed: () => { Navigator.pop(context1); }), } ) ); })); } ) }, backgroundColor: new Color(0xFF212121) ), body: new Container( margin: EdgeInsets.all(15), decoration: new BoxDecoration(), child: new TextField( style: new TextStyle(fontSize: 18, color: Colors.white70), decoration: new InputDecoration( fillColor: new Color(0xFF424242), filled: true, hasFloatingPlaceholder: false, hintText: "New Habit", contentPadding: EdgeInsets.all(6), focusedBorder: new OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(6)), borderSide: new BorderSide(width: 0, color: new Color(0xFF424242)) ) ), controller: new TextEditingController(widget.CreateMode ? string.Empty : widget.Habit.Title), onSubmitted: (value => { if (widget.CreateMode) { dispatcher.dispatch(new AddHabitAction(new HabitData(value))); } else { if (value != widget.Habit.Title) { dispatcher.dispatch(new UpdateHabitAction(widget.Habit, value)); } } Navigator.pop(context); })) ) ); } )); }
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))); } ) } ), } ) ) ) } ) ) ); } )); }