Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Mute Unmute Issue on Entity and Council Page #365

Merged
merged 10 commits into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/screens/newProfileScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -371,16 +371,16 @@ class _ProfileScreenState extends State<ProfileScreen> {
decoration: BoxDecoration(
image: DecorationImage(
image: (showingClubPrivileges)
? widget.profileDetails.club_privileges[index]
.small_image_url ==
? (widget.profileDetails.club_privileges[index]
.small_image_url !=
null
? NetworkImage(
widget
.profileDetails
.club_privileges[index]
.small_image_url,
)
: AssetImage('assets/iitbhu.jpeg')
: AssetImage('assets/iitbhu.jpeg'))
: NetworkImage(
widget
.profileDetails
Expand Down Expand Up @@ -432,6 +432,8 @@ class _ProfileScreenState extends State<ProfileScreen> {
Widget _buildFollowing(BuildContext context) {
int clubSubscriptions = widget.profileDetails.club_subscriptions.length;
int entitySubscriptions = widget.profileDetails.entity_subscriptions.length;

// debugPrint(widget.profileDetails.club_subscriptions.toString());
return (clubSubscriptions + entitySubscriptions == 0)
? Container(
// If the User does not have any subscriptions.
Expand Down Expand Up @@ -467,8 +469,8 @@ class _ProfileScreenState extends State<ProfileScreen> {
Stack(
children: [
Container(
height: 90.0,
width: 90.0,
height: 80.0,
width: 80.0,
decoration: BoxDecoration(
image: DecorationImage(
image: (showingClubSubscriptions)
Expand Down
196 changes: 119 additions & 77 deletions lib/ui/club_council_entity_common/club_council_entity_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import 'package:iit_app/ui/separator.dart';
import 'package:iit_app/ui/text_style.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:fluttertoast/fluttertoast.dart';

class ClubCouncilAndEntityWidgets {
static Widget getPanelBackground(
Expand Down Expand Up @@ -173,7 +174,7 @@ class ClubCouncilAndEntityWidgets {
isEntity: isEntity,
isSports: (isClub && club.council.name.contains('Sport')),
),
_data != null
(_data != null && isCouncil==false)
? getSubscribeButtons(
context: context,
isCouncil: isCouncil,
Expand Down Expand Up @@ -245,10 +246,11 @@ class ClubCouncilAndEntityWidgets {
),
onPressed: AppConstants.isGuest
? () {
ScaffoldMessenger.of(context).removeCurrentSnackBar();
var snackbar =
SnackBar(content: Text("Please Log in to Mute"));
ScaffoldMessenger.of(context).showSnackBar(snackbar);
// ScaffoldMessenger.of(context)?.removeCurrentSnackBar();
// var snackbar =
// SnackBar(content: Text("Please Log in to Mute"));
// ScaffoldMessenger.of(context)?.showSnackBar(snackbar);
Fluttertoast.showToast(msg: "Please Log in to Mute");
}
: _disableMuteButton // disable mute button if not subscribed in case of club/entity.
? null
Expand All @@ -265,13 +267,17 @@ class ClubCouncilAndEntityWidgets {
"Are you sure you wish to mute all the clubs in this council? You will no longer receive any notification for workshops or events of this council.",
);
if (unsub) {
scaffoldMessengerKey.currentState
.removeCurrentSnackBar();
scaffoldMessengerKey.currentState
.showSnackBar(SnackBar(
content: Text('Muting. Please Wait'),
duration: Duration(seconds: 10),
));
// await scaffoldMessengerKey.currentState
// ?.removeCurrentSnackBar();

// scaffoldMessengerKey.currentState
// ?.showSnackBar(SnackBar(
// content: Text('Muting. Please Wait'),
// duration: Duration(seconds: 10),
// ));
Fluttertoast.showToast(
msg:"Muting. Please Wait"
);
List<int> clubIds = await AppConstants
.updateCouncilSubscriptionInDatabase(
councilId: councilId, isSubscribed: false);
Expand All @@ -289,13 +295,16 @@ class ClubCouncilAndEntityWidgets {
.then((_) =>
print('Unsubscribed from C_$i'));
}
scaffoldMessengerKey.currentState
.removeCurrentSnackBar();
scaffoldMessengerKey.currentState
.showSnackBar(SnackBar(
content: Text('Successfully Muted!'),
duration: Duration(seconds: 3),
));
// scaffoldMessengerKey.currentState
// ?.removeCurrentSnackBar();
// scaffoldMessengerKey.currentState
// ?.showSnackBar(SnackBar(
// content: Text('Successfully Muted!'),
// duration: Duration(seconds: 3),
// ));
Fluttertoast.showToast(
msg:"Successfully Muted!"
);
}
Shubham9455 marked this conversation as resolved.
Show resolved Hide resolved
}).catchError((onError) {
if (onError is InternetConnectionException) {
Expand Down Expand Up @@ -348,11 +357,14 @@ class ClubCouncilAndEntityWidgets {
.unsubscribeFromTopic(
'C_${clubMap.id}');
}
scaffoldMessengerKey.currentState
.showSnackBar(SnackBar(
content: Text('Successfully Muted'),
duration: Duration(seconds: 3),
));
// scaffoldMessengerKey.currentState
// ?.showSnackBar(SnackBar(
// content: Text('Successfully Muted'),
// duration: Duration(seconds: 3),
// ));
Fluttertoast.showToast(
msg:"Successfully Muted"
);
} on InternetConnectionException catch (_) {
AppConstants.internetErrorFlushBar
.showFlushbar(context);
Expand All @@ -371,11 +383,14 @@ class ClubCouncilAndEntityWidgets {
"Error in toggleing: ${onError.toString()}");
});
} else {
scaffoldMessengerKey.currentState
.showSnackBar(SnackBar(
content: Text('Already Muted!'),
duration: Duration(seconds: 3),
));
// scaffoldMessengerKey.currentState
// ?.showSnackBar(SnackBar(
// content: Text('Already Muted!'),
// duration: Duration(seconds: 3),
// ));
Fluttertoast.showToast(
msg:"Already Muted!"
);
}
}
} else {
Expand Down Expand Up @@ -421,11 +436,14 @@ class ClubCouncilAndEntityWidgets {
'E_${entityMap.id}');
}

scaffoldMessengerKey.currentState
.showSnackBar(SnackBar(
content: Text('Successfully Muted'),
duration: Duration(seconds: 3),
));
// scaffoldMessengerKey.currentState
// ?.showSnackBar(SnackBar(
// content: Text('Successfully Muted'),
// duration: Duration(seconds: 3),
// ));
Fluttertoast.showToast(
msg:"Successfully Muted"
);
} on InternetConnectionException catch (_) {
AppConstants.internetErrorFlushBar
.showFlushbar(context);
Expand All @@ -444,11 +462,14 @@ class ClubCouncilAndEntityWidgets {
"Error in toggleing: ${onError.toString()}");
});
} else {
scaffoldMessengerKey.currentState
.showSnackBar(SnackBar(
content: Text('Already Muted!'),
duration: Duration(seconds: 3),
));
// scaffoldMessengerKey.currentState
// ?.showSnackBar(SnackBar(
// content: Text('Already Muted!'),
// duration: Duration(seconds: 3),
// ));
Fluttertoast.showToast(
msg:"Already Muted!"
);
}
}
}
Expand Down Expand Up @@ -486,24 +507,30 @@ class ClubCouncilAndEntityWidgets {
),
onPressed: AppConstants.isGuest
? () {
ScaffoldMessenger.of(context).removeCurrentSnackBar();
var snackbar =
SnackBar(content: Text("Please Log in to Unmute"));
ScaffoldMessenger.of(context).showSnackBar(snackbar);
// ScaffoldMessenger.of(context)?.removeCurrentSnackBar();
// var snackbar =
// SnackBar(content: Text("Please Log in to Unmute"));
// ScaffoldMessenger.of(context)?.showSnackBar(snackbar);
Fluttertoast.showToast(
msg:"Please Log in to Unmute"
);
}
: _disableUnmuteButton // disable unmute button if already subscribed in case of club/entity.
? null
: () async {
if (!toggling) {
toggler();
if (isCouncil) {
scaffoldMessengerKey.currentState
.removeCurrentSnackBar();
scaffoldMessengerKey.currentState
.showSnackBar(SnackBar(
content: Text('Unmuting. Please Wait'),
duration: Duration(seconds: 10),
));
// scaffoldMessengerKey.currentState
// ?.removeCurrentSnackBar();
// scaffoldMessengerKey.currentState
// ?.showSnackBar(SnackBar(
// content: Text('Unmuting. Please Wait'),
// duration: Duration(seconds: 10),
// ));
Fluttertoast.showToast(
msg:"Unmuting. Please Wait"
);
int councilId = data.id;
List<int> clubIds = await AppConstants
.updateCouncilSubscriptionInDatabase(
Expand All @@ -521,13 +548,16 @@ class ClubCouncilAndEntityWidgets {
.subscribeToTopic('C_$i')
.then((_) => print('Subscribed to C_$i'));
}
scaffoldMessengerKey.currentState
.removeCurrentSnackBar();
scaffoldMessengerKey.currentState
.showSnackBar(SnackBar(
content: Text('Successfully Unmuted!'),
duration: Duration(seconds: 3),
));
// scaffoldMessengerKey.currentState
// ?.removeCurrentSnackBar();
// scaffoldMessengerKey.currentState
// ?.showSnackBar(SnackBar(
// content: Text('Successfully Unmuted!'),
// duration: Duration(seconds: 3),
// ));
Fluttertoast.showToast(
msg:"Successfully Unmuted!"
);
}
}).catchError((onError) {
if (onError is InternetConnectionException) {
Expand Down Expand Up @@ -571,11 +601,14 @@ class ClubCouncilAndEntityWidgets {
.unsubscribeFromTopic(
'C_${clubMap.id}');
}
scaffoldMessengerKey.currentState
.showSnackBar(SnackBar(
content: Text('Successfully Unmuted!'),
duration: Duration(seconds: 3),
));
// scaffoldMessengerKey.currentState
// ?.showSnackBar(SnackBar(
// content: Text('Successfully Unmuted!'),
// duration: Duration(seconds: 3),
// ));
Fluttertoast.showToast(
msg:"Successfully Unmuted!"
);
} on InternetConnectionException catch (_) {
AppConstants.internetErrorFlushBar
.showFlushbar(context);
Expand All @@ -594,11 +627,14 @@ class ClubCouncilAndEntityWidgets {
"Error in toggleing: ${onError.toString()}");
});
} else {
scaffoldMessengerKey.currentState
.showSnackBar(SnackBar(
content: Text('Already Unmuted!'),
duration: Duration(seconds: 3),
));
// scaffoldMessengerKey.currentState
// ?.showSnackBar(SnackBar(
// content: Text('Already Unmuted!'),
// duration: Duration(seconds: 3),
// ));
Fluttertoast.showToast(
msg:"Already Unmuted!"
);
}
} else {
if (!data.is_subscribed) {
Expand Down Expand Up @@ -634,11 +670,14 @@ class ClubCouncilAndEntityWidgets {
.unsubscribeFromTopic(
'E_${entityMap.id}');
}
scaffoldMessengerKey.currentState
.showSnackBar(SnackBar(
content: Text('Successfully Unmuted!'),
duration: Duration(seconds: 3),
));
// scaffoldMessengerKey.currentState
// ?.showSnackBar(SnackBar(
// content: Text('Successfully Unmuted!'),
// duration: Duration(seconds: 3),
// ));
Fluttertoast.showToast(
msg:"Successfully Unmuted!"
);
} on InternetConnectionException catch (_) {
AppConstants.internetErrorFlushBar
.showFlushbar(context);
Expand All @@ -657,11 +696,14 @@ class ClubCouncilAndEntityWidgets {
"Error in toggleing: ${onError.toString()}");
});
} else {
scaffoldMessengerKey.currentState
.showSnackBar(SnackBar(
content: Text('Already Unuted!'),
duration: Duration(seconds: 3),
));
// scaffoldMessengerKey.currentState
// ?.showSnackBar(SnackBar(
// content: Text('Already Unuted!'),
// duration: Duration(seconds: 3),
// ));
Fluttertoast.showToast(
msg:"Already Unmuted!"
);
}
}
toggler();
Expand Down
3 changes: 3 additions & 0 deletions lib/ui/club_entity_common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class ClubAndEntityWidgets {
child: Column(
children: [
TabBar(
onTap: (value) {
panelController.panelPosition = 1.0;
},
Shubham9455 marked this conversation as resolved.
Show resolved Hide resolved
indicatorSize: TabBarIndicatorSize.tab,
indicatorColor: ColorConstants.headingColor,
tabs: [
Expand Down
Loading