Skip to content

Commit

Permalink
[BottomDrawer] fix height in landscape; [BodyPage] implement complete…
Browse files Browse the repository at this point in the history
… list;
  • Loading branch information
tastelessjolt committed Dec 24, 2018
1 parent cba37f8 commit 6f92db2
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 151 deletions.
6 changes: 6 additions & 0 deletions lib/src/api/model/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ class User {

@Alias('former_roles')
List<Role> formerRoles;

String currentRole;

String getSubTitle() {
return currentRole ?? ldapId;
}
}

@GenSerializer(serializers: const [UserSerializer])
Expand Down
18 changes: 17 additions & 1 deletion lib/src/blocs/ia_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ class InstiAppBloc {
}

Future<Event> getEvent(String uuid) async {
return _events?.firstWhere((event) => event.eventID == uuid) ?? client.getEvent(getSessionIdHeader(), uuid);
try {
return _events?.firstWhere((event) => event.eventID == uuid);
}
catch (ex) {
print(ex);
return client.getEvent(getSessionIdHeader(), uuid);
}
// return client.getEvent(getSessionIdHeader(), uuid);
}

Expand Down Expand Up @@ -110,6 +116,16 @@ class InstiAppBloc {
}
}

Future<void> updateFollowBody(Body b) async {
try {
await client.updateBodyFollowing(getSessionIdHeader(), b.bodyID, b.bodyUserFollows ? 0 : 1);
b.bodyUserFollows = !b.bodyUserFollows;
b.bodyFollowersCount += b.bodyUserFollows ? 1 : -1;
} catch (ex) {
print(ex);
}
}

void _persistSession(Session sess) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString("session", standardSerializers.encode(sess));
Expand Down
2 changes: 1 addition & 1 deletion lib/src/drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class _BottomDrawerState extends State<BottomDrawer> {
var drawerState = bloc.drawerState;
return ScrollableBottomSheet(
snapAbove: true,
initialHeight: 300.0,
initialHeight: MediaQuery.of(context).size.height / 2 - 20,
child: StreamBuilder<Session>(
stream: bloc.session,
builder: (BuildContext context, AsyncSnapshot<Session> snapshot) {
Expand Down
136 changes: 5 additions & 131 deletions lib/src/routes/blogpage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ class _BlogPageState extends State<BlogPage> {
});
_scaffoldKey.currentState
.showBottomSheet((context) {
// BottomDrawer.setPageIndex(
// bloc,
// widget.blogType == BlogType.Placement
// ? 4
// : 5);
BottomDrawer.setPageIndex(
bloc,
widget.blogType == BlogType.Placement
? 4
: 5);
return BottomDrawer();
})
.closed
Expand Down Expand Up @@ -253,132 +253,6 @@ class _BlogPageState extends State<BlogPage> {
},
),
),
// persistentFooterButtons: footerButtons,
);
return Scaffold(
key: _scaffoldKey,
appBar: AppBar(
leading: IconButton(
icon: Icon(
OMIcons.menu,
color: Colors.white,
),
onPressed: () {
_scaffoldKey.currentState.openDrawer();
},
),
actions: <Widget>[
IconButton(
icon: Icon(actionIcon),
onPressed: () {
setState(() {
if (searchMode) {
actionIcon = OMIcons.search;
blogBloc.query = "";
blogBloc.refresh();
} else {
actionIcon = OMIcons.close;
}

searchMode = !searchMode;
});
},
)
],
title: Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: ImageIcon(
AssetImage('assets/lotus.png'),
color: Colors.white,
),
),
Text(widget.title,
style: theme.textTheme.headline
.copyWith(fontFamily: "Bitter", color: Colors.white)),
],
),
bottom: searchMode
? PreferredSize(
preferredSize: Size.fromHeight(48.0),
child: TextField(
style: TextStyle(
color: Colors.white,
),
decoration: InputDecoration(
prefixIcon: Icon(OMIcons.search, color: Colors.white),
hintText: "Search...",
hintStyle: TextStyle(color: Colors.white)),
onChanged: (query) async {
if (query.length > 4) {
blogBloc.query = query;
blogBloc.refresh();
}
},
onSubmitted: (query) async {
blogBloc.query = query;
await blogBloc.refresh();
},
),
)
: null,
),
drawer: DrawerOnly(),
body: StreamBuilder(
stream: bloc.session,
builder: (BuildContext context, AsyncSnapshot<Session> snapshot) {
if (snapshot.hasData && snapshot.data != null) {
return StreamBuilder(
stream: blogBloc.blog,
builder: (BuildContext context,
AsyncSnapshot<UnmodifiableListView<BlogPost>> snapshot) {
return RefreshIndicator(
key: _refreshIndicatorKey,
onRefresh: _handleRefresh,
child: ListView.builder(
scrollDirection: Axis.vertical,
itemBuilder: (BuildContext context, int index) {
return _buildBlogPost(blogBloc, index, snapshot.data);
},
itemCount:
(snapshot.data == null ? 0 : snapshot.data.length) + 1,
controller: _hideButtonController,
),
);
},
);
} else {
return Center(
child: Text(
"You must be logged in to view ${widget.title}",
style: theme.textTheme.title,
textAlign: TextAlign.center,
),
);
}
},
),
floatingActionButtonAnimator: FloatingActionButtonAnimator.scaling,
floatingActionButton: isFabVisible == 0
? null
: FloatingActionButton(
onPressed: () {
_hideButtonController
.animateTo(0.0,
curve: Curves.fastOutSlowIn,
duration: const Duration(milliseconds: 600))
.then((_) {
setState(() {
isFabVisible = 0.0;
});
});
setState(() {
isFabVisible = 0.0;
});
},
child: Icon(OMIcons.keyboardArrowUp),
),
);
}

Expand Down
Loading

0 comments on commit 6f92db2

Please sign in to comment.