Skip to content

Commit

Permalink
feat: removed the tab bar if the user has no relation. Fix Issue anit…
Browse files Browse the repository at this point in the history
  • Loading branch information
justdvnsh committed Aug 4, 2020
1 parent 48c1237 commit 2597839
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions lib/screens/home/pages/relation/relation_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import 'package:mentorship_client/widgets/loading_indicator.dart';
import 'package:auto_size_text/auto_size_text.dart';

class RelationPage extends StatefulWidget {
bool _isAppbarVisible = true;
@override
_RelationPageState createState() => _RelationPageState();
}

class _RelationPageState extends State<RelationPage> {
Completer<void> _refreshCompleter;
bool _isAppbarVisible = true;

@override
void initState() {
Expand All @@ -33,26 +33,20 @@ class _RelationPageState extends State<RelationPage> {
return DefaultTabController(
length: 2,
child: Scaffold(
appBar: _isAppbarVisible ? TabBar(
labelColor: Theme.of(context).accentColor,
tabs: [
Tab(text: "Details".toUpperCase()),
Tab(text: "Tasks".toUpperCase()),
]
) : null,
appBar: _buildAppBar(null),
body: BlocConsumer<RelationPageBloc, RelationPageState>(listener: (context, state) {
if (state.message != null && state is RelationPageSuccess) {
context.showSnackBar(state.message);
Navigator.of(context).pop();
_buildAppBar(state);
}
if (state is RelationPageShowed) {
_refreshCompleter?.complete();
_refreshCompleter = Completer();
_buildAppBar(state);
}
if (state is RelationPageFailure) {
setState(() {
_isAppbarVisible = false;
});
_buildAppBar(state);
}
}, builder: (context, state) {
return BlocBuilder<RelationPageBloc, RelationPageState>(
Expand Down Expand Up @@ -121,6 +115,18 @@ class _RelationPageState extends State<RelationPage> {
);
}

// build the tab bar
Widget _buildAppBar(RelationPageState state) {
return state is RelationPageSuccess || state is RelationPageShowed ?
TabBar(
labelColor: Theme.of(context).accentColor,
tabs: [
Tab(text: "Details".toUpperCase()),
Tab(text: "Tasks".toUpperCase()),
]
) : null;
}

Widget _buildDetailsTab(BuildContext context, RelationPageSuccess state) {
return RefreshIndicator(
onRefresh: () {
Expand Down

0 comments on commit 2597839

Please sign in to comment.