Skip to content

Commit

Permalink
feat: Community/tag actions for unlogged will redirect to login
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-bak committed Feb 23, 2023
1 parent f978a57 commit 1b38d02
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 43 deletions.
46 changes: 25 additions & 21 deletions lib/ui/community_screen/community_app_bar.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:cached_network_image/cached_network_image.dart';

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hejtter/logic/bloc/profile_bloc/profile_bloc.dart';
import 'package:hejtter/models/communities_response.dart';

class CommunityAppBar extends StatelessWidget {
Expand Down Expand Up @@ -40,28 +42,30 @@ class CommunityAppBar extends StatelessWidget {
return SliverAppBar.large(
pinned: true,
actions: [
PopupMenuButton<String>(
onSelected: (_) {},
itemBuilder: (BuildContext context) {
return moreButtonOptions.map((String choice) {
return PopupMenuItem<String>(
value: choice,
child: Text(choice),
onTap: () {
if (choice == 'Opuść') {
changeCommunityMembership(false);
} else if (choice == 'Dołącz') {
changeCommunityMembership(true);
} else if (choice == 'Odblokuj') {
changeCommunityBlockState(false);
} else if (choice == 'Zablokuj') {
changeCommunityBlockState(true);
}
(context.read<ProfileBloc>().state is ProfilePresentState)
? PopupMenuButton<String>(
onSelected: (_) {},
itemBuilder: (BuildContext context) {
return moreButtonOptions.map((String choice) {
return PopupMenuItem<String>(
value: choice,
child: Text(choice),
onTap: () {
if (choice == 'Opuść') {
changeCommunityMembership(false);
} else if (choice == 'Dołącz') {
changeCommunityMembership(true);
} else if (choice == 'Odblokuj') {
changeCommunityBlockState(false);
} else if (choice == 'Zablokuj') {
changeCommunityBlockState(true);
}
},
);
}).toList();
},
);
}).toList();
},
),
)
: const SizedBox(),
],
title: Row(
children: [
Expand Down
13 changes: 12 additions & 1 deletion lib/ui/post_screen/answer_button.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hejtter/logic/bloc/profile_bloc/profile_bloc.dart';
import 'package:hejtter/ui/login_screen/login_screen.dart';

class AnswerButton extends StatelessWidget {
const AnswerButton({
Expand All @@ -15,7 +18,15 @@ class AnswerButton extends StatelessWidget {
Widget build(BuildContext context) {
return TextButton(
style: TextButton.styleFrom(foregroundColor: Colors.white),
onPressed: () => respondToUser(username),
onPressed: () {
if (context.read<ProfileBloc>().state is ProfilePresentState) {
respondToUser(username);
} else {
Navigator.push(context, MaterialPageRoute(builder: (_) {
return const LoginScreen();
}));
}
},
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Expand Down
46 changes: 25 additions & 21 deletions lib/ui/tag_screen/tag_app_bar.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hejtter/logic/bloc/profile_bloc/profile_bloc.dart';
import 'package:hejtter/models/hejto_tag.dart';

class TagAppBar extends StatelessWidget {
Expand Down Expand Up @@ -38,28 +40,30 @@ class TagAppBar extends StatelessWidget {
return SliverAppBar.medium(
pinned: true,
actions: [
PopupMenuButton<String>(
onSelected: (_) {},
itemBuilder: (BuildContext context) {
return moreButtonOptions.map((String choice) {
return PopupMenuItem<String>(
value: choice,
child: Text(choice),
onTap: () {
if (choice == 'Przestań obserwować') {
changeTagFollowState(false);
} else if (choice == 'Obserwuj') {
changeTagFollowState(true);
} else if (choice == 'Odblokuj') {
changeTagBlockState(false);
} else if (choice == 'Zablokuj') {
changeTagBlockState(true);
}
(context.read<ProfileBloc>().state is ProfilePresentState)
? PopupMenuButton<String>(
onSelected: (_) {},
itemBuilder: (BuildContext context) {
return moreButtonOptions.map((String choice) {
return PopupMenuItem<String>(
value: choice,
child: Text(choice),
onTap: () {
if (choice == 'Przestań obserwować') {
changeTagFollowState(false);
} else if (choice == 'Obserwuj') {
changeTagFollowState(true);
} else if (choice == 'Odblokuj') {
changeTagBlockState(false);
} else if (choice == 'Zablokuj') {
changeTagBlockState(true);
}
},
);
}).toList();
},
);
}).toList();
},
),
)
: const SizedBox(),
],
title: Text(
'#${tag.name}',
Expand Down

0 comments on commit 1b38d02

Please sign in to comment.