diff --git a/lib/models_new/live/live_area_list/area_item.dart b/lib/models_new/live/live_area_list/area_item.dart index b8e1abf3..54cb8364 100644 --- a/lib/models_new/live/live_area_list/area_item.dart +++ b/lib/models_new/live/live_area_list/area_item.dart @@ -8,8 +8,6 @@ class AreaItem { int? areaType; int? tagType; - bool? isFav; - AreaItem({ this.id, this.name, diff --git a/lib/pages/emote/view.dart b/lib/pages/emote/view.dart index 22c257ad..97c780d9 100644 --- a/lib/pages/emote/view.dart +++ b/lib/pages/emote/view.dart @@ -124,7 +124,7 @@ class _EmotePanelState extends State type: MaterialType.transparency, child: InkWell( borderRadius: - const BorderRadius.all(Radius.circular(8)), + const BorderRadius.all(Radius.circular(6)), onTap: () => widget.onChoose( item, isTextEmote diff --git a/lib/pages/live_area/controller.dart b/lib/pages/live_area/controller.dart index d91e2101..3763047f 100644 --- a/lib/pages/live_area/controller.dart +++ b/lib/pages/live_area/controller.dart @@ -12,6 +12,7 @@ class LiveAreaController AccountService accountService = Get.find(); late final isEditing = false.obs; + late final favInfo = {}; @override void onInit() { diff --git a/lib/pages/live_area/view.dart b/lib/pages/live_area/view.dart index 4abb971e..b87ca015 100644 --- a/lib/pages/live_area/view.dart +++ b/lib/pages/live_area/view.dart @@ -110,21 +110,25 @@ class _LiveAreaPageState extends State { item: item, onPressed: () { // success - if (item.isFav == true) { + bool? isFav = + _controller.favInfo[item.id]; + if (isFav == true) { + _controller.favInfo[item.id] = + false; _controller.favState ..value.data.remove(item) ..refresh(); - item.isFav = false; (context as Element) .markNeedsBuild(); } else { // check if (_controller .favState.value.isSuccess) { + _controller.favInfo[item.id] = + true; _controller.favState ..value.data.add(item) ..refresh(); - item.isFav = true; (context as Element) .markNeedsBuild(); } @@ -190,26 +194,9 @@ class _LiveAreaPageState extends State { item: item, onPressed: () { list.remove(item); - _controller.favState.refresh(); - - // update isFav - if (_controller.loadingState.value.isSuccess) { - List? 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; - } - } - } - } - } - } + _controller + ..favInfo[item.id] = false + ..favState.refresh(); }, ), ) @@ -277,26 +264,19 @@ class _LiveAreaPageState extends State { child: Obx(() { if (_controller.isEditing.value && _controller.favState.value.isSuccess) { - // init isFav - item.isFav ??= _controller.favState.value.data.contains(item); - - return Builder( - builder: (context) { - return iconButton( - size: 17, - iconSize: 13, - context: context, - icon: - item.isFav == true ? MdiIcons.check : MdiIcons.plus, - bgColor: item.isFav == true - ? theme.colorScheme.onInverseSurface - : null, - iconColor: item.isFav == true - ? theme.colorScheme.outline - : null, - onPressed: onPressed, - ); - }, + bool? isFav = _controller.favInfo[item.id]; + if (isFav == null) { + isFav = _controller.favState.value.data.contains(item); + _controller.favInfo[item.id] = isFav; + } + return iconButton( + size: 17, + iconSize: 13, + context: context, + icon: isFav ? MdiIcons.check : MdiIcons.plus, + bgColor: isFav ? theme.colorScheme.onInverseSurface : null, + iconColor: isFav ? theme.colorScheme.outline : null, + onPressed: onPressed, ); } return const SizedBox.shrink(); diff --git a/lib/pages/live_emote/view.dart b/lib/pages/live_emote/view.dart index 700d6606..99f0c011 100644 --- a/lib/pages/live_emote/view.dart +++ b/lib/pages/live_emote/view.dart @@ -82,7 +82,7 @@ class _LiveEmotePanelState extends State type: MaterialType.transparency, child: InkWell( borderRadius: - const BorderRadius.all(Radius.circular(8)), + const BorderRadius.all(Radius.circular(6)), onTap: () { if (item.pkgType == 3) { widget.onChoose(e, width, height);