2025-01-14 09:31:43 +08:00
|
|
|
import 'package:appflowy/plugins/base/emoji/emoji_text.dart';
|
2024-12-19 15:19:10 +08:00
|
|
|
import 'package:appflowy/shared/icon_emoji_picker/icon_picker.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import '../../../generated/flowy_svgs.g.dart';
|
|
|
|
|
|
|
|
class IconWidget extends StatelessWidget {
|
2025-01-14 09:31:43 +08:00
|
|
|
const IconWidget({super.key, required this.size, required this.iconsData});
|
2024-12-19 15:19:10 +08:00
|
|
|
|
2025-01-14 09:31:43 +08:00
|
|
|
final IconsData iconsData;
|
2024-12-19 15:19:10 +08:00
|
|
|
final double size;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2025-01-14 09:31:43 +08:00
|
|
|
final colorValue = int.tryParse(iconsData.color ?? '');
|
2024-12-19 15:19:10 +08:00
|
|
|
Color? color;
|
|
|
|
if (colorValue != null) {
|
|
|
|
color = Color(colorValue);
|
|
|
|
}
|
2025-01-14 09:31:43 +08:00
|
|
|
final svgString = iconsData.svgString;
|
|
|
|
if (svgString == null) {
|
|
|
|
return EmojiText(
|
|
|
|
emoji: '❓',
|
|
|
|
fontSize: size,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
);
|
|
|
|
}
|
2024-12-19 15:19:10 +08:00
|
|
|
return FlowySvg.string(
|
2025-01-14 09:31:43 +08:00
|
|
|
svgString,
|
2024-12-19 15:19:10 +08:00
|
|
|
size: Size.square(size),
|
|
|
|
color: color,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|