mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-22 01:56:47 +08:00
opt emote
opt live fav state Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -8,8 +8,6 @@ class AreaItem {
|
||||
int? areaType;
|
||||
int? tagType;
|
||||
|
||||
bool? isFav;
|
||||
|
||||
AreaItem({
|
||||
this.id,
|
||||
this.name,
|
||||
|
||||
@@ -124,7 +124,7 @@ class _EmotePanelState extends State<EmotePanel>
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(8)),
|
||||
const BorderRadius.all(Radius.circular(6)),
|
||||
onTap: () => widget.onChoose(
|
||||
item,
|
||||
isTextEmote
|
||||
|
||||
@@ -12,6 +12,7 @@ class LiveAreaController
|
||||
AccountService accountService = Get.find<AccountService>();
|
||||
|
||||
late final isEditing = false.obs;
|
||||
late final favInfo = {};
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
|
||||
@@ -110,21 +110,25 @@ class _LiveAreaPageState extends State<LiveAreaPage> {
|
||||
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<LiveAreaPage> {
|
||||
item: item,
|
||||
onPressed: () {
|
||||
list.remove(item);
|
||||
_controller.favState.refresh();
|
||||
|
||||
// update isFav
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_controller
|
||||
..favInfo[item.id] = false
|
||||
..favState.refresh();
|
||||
},
|
||||
),
|
||||
)
|
||||
@@ -277,26 +264,19 @@ class _LiveAreaPageState extends State<LiveAreaPage> {
|
||||
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();
|
||||
|
||||
@@ -82,7 +82,7 @@ class _LiveEmotePanelState extends State<LiveEmotePanel>
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user