Browse Source

fix deprecated flatbutton

pull/24/head
Neo Sun 3 years ago
parent
commit
19fac414f6
  1. 78
      lib/apps/file/editor.dart
  2. 87
      lib/utils/emoji_picker.dart

78
lib/apps/file/editor.dart

@ -185,10 +185,10 @@ class _EditorPageState extends State<EditorPage> { @@ -185,10 +185,10 @@ class _EditorPageState extends State<EditorPage> {
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<EditorPage> { @@ -206,31 +206,31 @@ class _EditorPageState extends State<EditorPage> {
);
}
Future<MediaPickSetting?> _selectMediaPickSetting(BuildContext context) {
final lang = AppLocalizations.of(context);
return showDialog<MediaPickSetting>(
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<MediaPickSetting?> _selectMediaPickSetting(BuildContext context) {
// final lang = AppLocalizations.of(context);
// return showDialog<MediaPickSetting>(
// 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<String> _checkName(String path, String name) async {
String tryName = name;
@ -245,14 +245,14 @@ class _EditorPageState extends State<EditorPage> { @@ -245,14 +245,14 @@ class _EditorPageState extends State<EditorPage> {
return path + name;
}
Future<String> _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<String> _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();
// }
}

87
lib/utils/emoji_picker.dart

@ -722,22 +722,21 @@ class _EmojiPickerState extends State<EmojiPicker> { @@ -722,22 +722,21 @@ class _EmojiPickerState extends State<EmojiPicker> {
SizedBox(
width: categoryWidth,
height: categoryWidth,
child: FlatButton(
padding: EdgeInsets.all(0),
color: widget.selectedCategory == Category.SMILEYS
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))),
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<EmojiPicker> { @@ -753,22 +752,23 @@ class _EmojiPickerState extends State<EmojiPicker> {
SizedBox(
width: categoryWidth,
height: categoryWidth,
child: FlatButton(
child: TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.all(0),
color: widget.selectedCategory == Category.ANIMALS
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<EmojiPicker> { @@ -785,21 +785,22 @@ class _EmojiPickerState extends State<EmojiPicker> {
SizedBox(
width: categoryWidth,
height: categoryWidth,
child: FlatButton(
child: TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.all(0),
color: widget.selectedCategory == Category.FOODS
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<EmojiPicker> { @@ -817,22 +818,22 @@ class _EmojiPickerState extends State<EmojiPicker> {
SizedBox(
width: categoryWidth,
height: categoryWidth,
child: FlatButton(
child: TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.all(0),
color: widget.selectedCategory == Category.TRAVEL
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<EmojiPicker> { @@ -851,23 +852,22 @@ class _EmojiPickerState extends State<EmojiPicker> {
SizedBox(
width: categoryWidth,
height: categoryWidth,
child: FlatButton(
child: TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.all(0),
color:
widget.selectedCategory == Category.ACTIVITIES
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<EmojiPicker> { @@ -888,22 +888,22 @@ class _EmojiPickerState extends State<EmojiPicker> {
SizedBox(
width: categoryWidth,
height: categoryWidth,
child: FlatButton(
child: TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.all(0),
color: widget.selectedCategory == Category.OBJECTS
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<EmojiPicker> { @@ -924,22 +924,22 @@ class _EmojiPickerState extends State<EmojiPicker> {
SizedBox(
width: categoryWidth,
height: categoryWidth,
child: FlatButton(
child: TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.all(0),
color: widget.selectedCategory == Category.SYMBOLS
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<EmojiPicker> { @@ -961,21 +961,22 @@ class _EmojiPickerState extends State<EmojiPicker> {
SizedBox(
width: categoryWidth,
height: categoryWidth,
child: FlatButton(
child: TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.all(0),
color: widget.selectedCategory == Category.FLAGS
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,
),
),

Loading…
Cancel
Save