Morn 00cdbe5a1c
fix: issues related to the emoji icon picker (#7063)
* fix: remove the scrolling conflict of the icon picker on macOS

* fix: the icon is not supported in sites tab

* feat: keep the icon panel open after click ramdom

* feat: the type of selector opened depends on the already set icon or emoji

* feat: the skin tone of the random emoji follows the selected skin ton

* fix: unit testing error
2024-12-30 16:42:14 +08:00

78 lines
1.8 KiB
Dart

import 'package:appflowy/mobile/presentation/home/tab/_round_underline_tab_indicator.dart';
import 'package:flutter/material.dart';
enum PickerTabType {
emoji,
icon;
String get tr {
switch (this) {
case PickerTabType.emoji:
return 'Emojis';
case PickerTabType.icon:
return 'Icons';
}
}
}
extension StringToPickerTabType on String {
PickerTabType? toPickerTabType() {
try {
return PickerTabType.values.byName(this);
} on ArgumentError {
return null;
}
}
}
class PickerTab extends StatelessWidget {
const PickerTab({
super.key,
this.onTap,
required this.controller,
required this.tabs,
});
final List<PickerTabType> tabs;
final TabController controller;
final ValueChanged<int>? onTap;
@override
Widget build(BuildContext context) {
final baseStyle = Theme.of(context).textTheme.bodyMedium;
final style = baseStyle?.copyWith(
fontWeight: FontWeight.w500,
fontSize: 14.0,
height: 16.0 / 14.0,
);
return TabBar(
controller: controller,
indicatorSize: TabBarIndicatorSize.label,
indicatorColor: Theme.of(context).colorScheme.primary,
isScrollable: true,
labelStyle: style,
labelColor: baseStyle?.color,
labelPadding: const EdgeInsets.symmetric(horizontal: 12.0),
unselectedLabelStyle: style?.copyWith(
color: Theme.of(context).hintColor,
),
overlayColor: WidgetStateProperty.all(Colors.transparent),
indicator: RoundUnderlineTabIndicator(
width: 34.0,
borderSide: BorderSide(
color: Theme.of(context).colorScheme.primary,
width: 3,
),
),
onTap: onTap,
tabs: tabs
.map(
(tab) => Tab(
text: tab.tr,
),
)
.toList(),
);
}
}