mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 12:57:24 +00:00
add actions
This commit is contained in:
@@ -43,11 +43,28 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
||||
|
||||
void follow() async{
|
||||
if(isFollowing) return;
|
||||
String type = "";
|
||||
if(!data!.isFollowed) {
|
||||
await flyoutController.showFlyout(
|
||||
navigatorKey: App.rootNavigatorKey.currentState,
|
||||
builder: (context) =>
|
||||
MenuFlyout(
|
||||
items: [
|
||||
MenuFlyoutItem(text: Text("Public".tl),
|
||||
onPressed: () => type = "public"),
|
||||
MenuFlyoutItem(text: Text("Private".tl),
|
||||
onPressed: () => type = "private"),
|
||||
],
|
||||
));
|
||||
}
|
||||
if(type.isEmpty && !data!.isFollowed) {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
isFollowing = true;
|
||||
});
|
||||
var method = data!.isFollowed ? "delete" : "add";
|
||||
var res = await Network().follow(data!.id.toString(), method);
|
||||
var res = await Network().follow(data!.id.toString(), method, type);
|
||||
if(res.error) {
|
||||
if(mounted) {
|
||||
context.showToast(message: "Network Error");
|
||||
@@ -61,6 +78,8 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
||||
});
|
||||
}
|
||||
|
||||
var flyoutController = FlyoutController();
|
||||
|
||||
Widget buildUser() {
|
||||
return SliverToBoxAdapter(
|
||||
child: Column(
|
||||
@@ -112,7 +131,10 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
||||
),
|
||||
))
|
||||
else if (!data!.isFollowed)
|
||||
Button(onPressed: follow, child: Text("Follow".tl))
|
||||
FlyoutTarget(
|
||||
controller: flyoutController,
|
||||
child: Button(onPressed: follow, child: Text("Follow".tl))
|
||||
)
|
||||
else
|
||||
Button(
|
||||
onPressed: follow,
|
||||
|
Reference in New Issue
Block a user