opt emote

opt live fav state

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-07-09 14:27:09 +08:00
parent 05153fda72
commit 753e10ef20
5 changed files with 26 additions and 47 deletions

View File

@@ -8,8 +8,6 @@ class AreaItem {
int? areaType; int? areaType;
int? tagType; int? tagType;
bool? isFav;
AreaItem({ AreaItem({
this.id, this.id,
this.name, this.name,

View File

@@ -124,7 +124,7 @@ class _EmotePanelState extends State<EmotePanel>
type: MaterialType.transparency, type: MaterialType.transparency,
child: InkWell( child: InkWell(
borderRadius: borderRadius:
const BorderRadius.all(Radius.circular(8)), const BorderRadius.all(Radius.circular(6)),
onTap: () => widget.onChoose( onTap: () => widget.onChoose(
item, item,
isTextEmote isTextEmote

View File

@@ -12,6 +12,7 @@ class LiveAreaController
AccountService accountService = Get.find<AccountService>(); AccountService accountService = Get.find<AccountService>();
late final isEditing = false.obs; late final isEditing = false.obs;
late final favInfo = {};
@override @override
void onInit() { void onInit() {

View File

@@ -110,21 +110,25 @@ class _LiveAreaPageState extends State<LiveAreaPage> {
item: item, item: item,
onPressed: () { onPressed: () {
// success // success
if (item.isFav == true) { bool? isFav =
_controller.favInfo[item.id];
if (isFav == true) {
_controller.favInfo[item.id] =
false;
_controller.favState _controller.favState
..value.data.remove(item) ..value.data.remove(item)
..refresh(); ..refresh();
item.isFav = false;
(context as Element) (context as Element)
.markNeedsBuild(); .markNeedsBuild();
} else { } else {
// check // check
if (_controller if (_controller
.favState.value.isSuccess) { .favState.value.isSuccess) {
_controller.favInfo[item.id] =
true;
_controller.favState _controller.favState
..value.data.add(item) ..value.data.add(item)
..refresh(); ..refresh();
item.isFav = true;
(context as Element) (context as Element)
.markNeedsBuild(); .markNeedsBuild();
} }
@@ -190,26 +194,9 @@ class _LiveAreaPageState extends State<LiveAreaPage> {
item: item, item: item,
onPressed: () { onPressed: () {
list.remove(item); list.remove(item);
_controller.favState.refresh(); _controller
..favInfo[item.id] = false
// update isFav ..favState.refresh();
if (_controller.loadingState.value.isSuccess) {
List<AreaList>? areaList =
_controller.loadingState.value.data;
if (areaList?.isNotEmpty == true) {
for (var i in areaList!) {
if (i.areaList?.isNotEmpty == true) {
for (var j in i.areaList!) {
if (j == item) {
j.isFav = false;
_controller.loadingState.refresh();
break;
}
}
}
}
}
}
}, },
), ),
) )
@@ -277,27 +264,20 @@ class _LiveAreaPageState extends State<LiveAreaPage> {
child: Obx(() { child: Obx(() {
if (_controller.isEditing.value && if (_controller.isEditing.value &&
_controller.favState.value.isSuccess) { _controller.favState.value.isSuccess) {
// init isFav bool? isFav = _controller.favInfo[item.id];
item.isFav ??= _controller.favState.value.data.contains(item); if (isFav == null) {
isFav = _controller.favState.value.data.contains(item);
return Builder( _controller.favInfo[item.id] = isFav;
builder: (context) { }
return iconButton( return iconButton(
size: 17, size: 17,
iconSize: 13, iconSize: 13,
context: context, context: context,
icon: icon: isFav ? MdiIcons.check : MdiIcons.plus,
item.isFav == true ? MdiIcons.check : MdiIcons.plus, bgColor: isFav ? theme.colorScheme.onInverseSurface : null,
bgColor: item.isFav == true iconColor: isFav ? theme.colorScheme.outline : null,
? theme.colorScheme.onInverseSurface
: null,
iconColor: item.isFav == true
? theme.colorScheme.outline
: null,
onPressed: onPressed, onPressed: onPressed,
); );
},
);
} }
return const SizedBox.shrink(); return const SizedBox.shrink();
}), }),

View File

@@ -82,7 +82,7 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
type: MaterialType.transparency, type: MaterialType.transparency,
child: InkWell( child: InkWell(
borderRadius: borderRadius:
const BorderRadius.all(Radius.circular(8)), const BorderRadius.all(Radius.circular(6)),
onTap: () { onTap: () {
if (item.pkgType == 3) { if (item.pkgType == 3) {
widget.onChoose(e, width, height); widget.onChoose(e, width, height);