From 19fac414f602cde26aa39afd6396dbdc71874f1a Mon Sep 17 00:00:00 2001 From: Neo Sun Date: Tue, 18 Oct 2022 22:41:35 +1300 Subject: [PATCH] fix deprecated flatbutton --- lib/apps/file/editor.dart | 78 ++++++++-------- lib/utils/emoji_picker.dart | 179 ++++++++++++++++++------------------ 2 files changed, 129 insertions(+), 128 deletions(-) diff --git a/lib/apps/file/editor.dart b/lib/apps/file/editor.dart index b670b5d..0de29ee 100644 --- a/lib/apps/file/editor.dart +++ b/lib/apps/file/editor.dart @@ -185,10 +185,10 @@ class _EditorPageState extends State { controller: this._controller!, showAlignmentButtons: true, multiRowsDisplay: isDesktop, - onImagePickCallback: _onImagePickCallback, - onVideoPickCallback: _onImagePickCallback, - mediaPickSettingSelector: _selectMediaPickSetting, - filePickImpl: pickMedia, + //onImagePickCallback: _onImagePickCallback, + //onVideoPickCallback: _onImagePickCallback, + //mediaPickSettingSelector: _selectMediaPickSetting, + //filePickImpl: pickMedia, showLink: false, ) ), @@ -206,31 +206,31 @@ class _EditorPageState extends State { ); } - Future _selectMediaPickSetting(BuildContext context) { - final lang = AppLocalizations.of(context); - return showDialog( - context: context, - builder: (ctx) => AlertDialog( - contentPadding: const EdgeInsets.all(20.0), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - TextButton.icon( - icon: const Icon(Icons.collections), - label: Text(lang.gallery), - onPressed: () => Navigator.pop(ctx, MediaPickSetting.Gallery), - ), - const Divider(height: 32.0), - TextButton.icon( - icon: const Icon(Icons.link), - label: Text(lang.link), - onPressed: () => Navigator.pop(ctx, MediaPickSetting.Link), - ) - ], - ), - ), - ); - } + // Future _selectMediaPickSetting(BuildContext context) { + // final lang = AppLocalizations.of(context); + // return showDialog( + // context: context, + // builder: (ctx) => AlertDialog( + // contentPadding: const EdgeInsets.all(20.0), + // content: Column( + // mainAxisSize: MainAxisSize.min, + // children: [ + // TextButton.icon( + // icon: const Icon(Icons.collections), + // label: Text(lang.gallery), + // onPressed: () => Navigator.pop(ctx, MediaPickSetting.Gallery), + // ), + // const Divider(height: 32.0), + // TextButton.icon( + // icon: const Icon(Icons.link), + // label: Text(lang.link), + // onPressed: () => Navigator.pop(ctx, MediaPickSetting.Link), + // ) + // ], + // ), + // ), + // ); + // } Future _checkName(String path, String name) async { String tryName = name; @@ -245,14 +245,14 @@ class _EditorPageState extends State { return path + name; } - Future _onImagePickCallback(File file) async { - final dir = Directory(Global.filePath + widget.path.did + '_assets'); - final isExists = await dir.exists(); - if (!isExists) { - await dir.create(recursive: true); - } - final pathname = await _checkName(dir.path + '/', basename(file.path)); - final copiedFile = await file.copy(pathname); - return copiedFile.path.toString(); - } + // Future _onImagePickCallback(File file) async { + // final dir = Directory(Global.filePath + widget.path.did + '_assets'); + // final isExists = await dir.exists(); + // if (!isExists) { + // await dir.create(recursive: true); + // } + // final pathname = await _checkName(dir.path + '/', basename(file.path)); + // final copiedFile = await file.copy(pathname); + // return copiedFile.path.toString(); + // } } diff --git a/lib/utils/emoji_picker.dart b/lib/utils/emoji_picker.dart index fefb0ab..88c253d 100644 --- a/lib/utils/emoji_picker.dart +++ b/lib/utils/emoji_picker.dart @@ -722,22 +722,21 @@ class _EmojiPickerState extends State { SizedBox( width: categoryWidth, height: categoryWidth, - child: FlatButton( - padding: EdgeInsets.all(0), - color: widget.selectedCategory == Category.SMILEYS - ? Colors.black12 - : Colors.transparent, - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.all(Radius.circular(0))), + child: TextButton( + style: TextButton.styleFrom(padding: EdgeInsets.all(0), + backgroundColor: widget.selectedCategory == Category.SMILEYS + ? Colors.black12 + : Colors.transparent, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.all(Radius.circular(0)))), child: Center( child: Icon( widget.categoryIcons!.smileyIcon.icon, size: 22, color: widget.selectedCategory == Category.SMILEYS - ? widget.categoryIcons!.smileyIcon - .selectedColor + ? widget.categoryIcons!.smileyIcon.selectedColor : widget.categoryIcons!.smileyIcon.color, ), ), @@ -753,22 +752,23 @@ class _EmojiPickerState extends State { SizedBox( width: categoryWidth, height: categoryWidth, - child: FlatButton( - padding: EdgeInsets.all(0), - color: widget.selectedCategory == Category.ANIMALS - ? Colors.black12 - : Colors.transparent, - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.all(Radius.circular(0))), + child: TextButton( + style: TextButton.styleFrom( + padding: EdgeInsets.all(0), + backgroundColor: widget.selectedCategory == Category.ANIMALS + ? Colors.black12 + : Colors.transparent, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.all(Radius.circular(0))), + ), child: Center( child: Icon( widget.categoryIcons!.animalIcon.icon, size: 22, color: widget.selectedCategory == Category.ANIMALS - ? widget.categoryIcons!.animalIcon - .selectedColor + ? widget.categoryIcons!.animalIcon.selectedColor : widget.categoryIcons!.animalIcon.color, ), ), @@ -785,21 +785,22 @@ class _EmojiPickerState extends State { SizedBox( width: categoryWidth, height: categoryWidth, - child: FlatButton( - padding: EdgeInsets.all(0), - color: widget.selectedCategory == Category.FOODS - ? Colors.black12 - : Colors.transparent, - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.all(Radius.circular(0))), + child: TextButton( + style: TextButton.styleFrom( + padding: EdgeInsets.all(0), + backgroundColor: widget.selectedCategory == Category.FOODS + ? Colors.black12 + : Colors.transparent, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.all(Radius.circular(0))), + ), child: Center( child: Icon( widget.categoryIcons!.foodIcon.icon, size: 22, color: widget.selectedCategory == Category.FOODS - ? widget - .categoryIcons!.foodIcon.selectedColor + ? widget.categoryIcons!.foodIcon.selectedColor : widget.categoryIcons!.foodIcon.color, ), ), @@ -817,22 +818,22 @@ class _EmojiPickerState extends State { SizedBox( width: categoryWidth, height: categoryWidth, - child: FlatButton( - padding: EdgeInsets.all(0), - color: widget.selectedCategory == Category.TRAVEL - ? Colors.black12 - : Colors.transparent, - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.all(Radius.circular(0))), + child: TextButton( + style: TextButton.styleFrom( + padding: EdgeInsets.all(0), + backgroundColor: widget.selectedCategory == Category.TRAVEL + ? Colors.black12 + : Colors.transparent, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.all(Radius.circular(0))), + ), child: Center( child: Icon( widget.categoryIcons!.travelIcon.icon, size: 22, - color: - widget.selectedCategory == Category.TRAVEL - ? widget.categoryIcons!.travelIcon - .selectedColor + color: widget.selectedCategory == Category.TRAVEL + ? widget.categoryIcons!.travelIcon.selectedColor : widget.categoryIcons!.travelIcon.color, ), ), @@ -851,23 +852,22 @@ class _EmojiPickerState extends State { SizedBox( width: categoryWidth, height: categoryWidth, - child: FlatButton( - padding: EdgeInsets.all(0), - color: - widget.selectedCategory == Category.ACTIVITIES - ? Colors.black12 - : Colors.transparent, - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.all(Radius.circular(0))), + child: TextButton( + style: TextButton.styleFrom( + padding: EdgeInsets.all(0), + backgroundColor: widget.selectedCategory == Category.ACTIVITIES + ? Colors.black12 + : Colors.transparent, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.all(Radius.circular(0))), + ), child: Center( child: Icon( widget.categoryIcons!.activityIcon.icon, size: 22, - color: widget.selectedCategory == - Category.ACTIVITIES - ? widget.categoryIcons!.activityIcon - .selectedColor + color: widget.selectedCategory == Category.ACTIVITIES + ? widget.categoryIcons!.activityIcon.selectedColor : widget.categoryIcons!.activityIcon.color, ), ), @@ -888,22 +888,22 @@ class _EmojiPickerState extends State { SizedBox( width: categoryWidth, height: categoryWidth, - child: FlatButton( - padding: EdgeInsets.all(0), - color: widget.selectedCategory == Category.OBJECTS - ? Colors.black12 - : Colors.transparent, - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.all(Radius.circular(0))), + child: TextButton( + style: TextButton.styleFrom( + padding: EdgeInsets.all(0), + backgroundColor: widget.selectedCategory == Category.OBJECTS + ? Colors.black12 + : Colors.transparent, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.all(Radius.circular(0))), + ), child: Center( child: Icon( widget.categoryIcons!.objectIcon.icon, size: 22, - color: - widget.selectedCategory == Category.OBJECTS - ? widget.categoryIcons!.objectIcon - .selectedColor + color: widget.selectedCategory == Category.OBJECTS + ? widget.categoryIcons!.objectIcon.selectedColor : widget.categoryIcons!.objectIcon.color, ), ), @@ -924,22 +924,22 @@ class _EmojiPickerState extends State { SizedBox( width: categoryWidth, height: categoryWidth, - child: FlatButton( - padding: EdgeInsets.all(0), - color: widget.selectedCategory == Category.SYMBOLS - ? Colors.black12 - : Colors.transparent, - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.all(Radius.circular(0))), + child: TextButton( + style: TextButton.styleFrom( + padding: EdgeInsets.all(0), + backgroundColor: widget.selectedCategory == Category.SYMBOLS + ? Colors.black12 + : Colors.transparent, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.all(Radius.circular(0))), + ), child: Center( child: Icon( widget.categoryIcons!.symbolIcon.icon, size: 22, - color: - widget.selectedCategory == Category.SYMBOLS - ? widget.categoryIcons!.symbolIcon - .selectedColor + color: widget.selectedCategory == Category.SYMBOLS + ? widget.categoryIcons!.symbolIcon.selectedColor : widget.categoryIcons!.symbolIcon.color, ), ), @@ -961,21 +961,22 @@ class _EmojiPickerState extends State { SizedBox( width: categoryWidth, height: categoryWidth, - child: FlatButton( - padding: EdgeInsets.all(0), - color: widget.selectedCategory == Category.FLAGS - ? Colors.black12 - : Colors.transparent, - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.all(Radius.circular(0))), + child: TextButton( + style: TextButton.styleFrom( + padding: EdgeInsets.all(0), + backgroundColor: widget.selectedCategory == Category.FLAGS + ? Colors.black12 + : Colors.transparent, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.all(Radius.circular(0))), + ), child: Center( child: Icon( widget.categoryIcons!.flagIcon.icon, size: 22, color: widget.selectedCategory == Category.FLAGS - ? widget - .categoryIcons!.flagIcon.selectedColor + ? widget.categoryIcons!.flagIcon.selectedColor : widget.categoryIcons!.flagIcon.color, ), ),