mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-24 12:32:40 +08:00
opt emote
opt live fav state Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user