Skip to content

Commit

Permalink
Using back button on mature widget, fixing some colors on light mode,…
Browse files Browse the repository at this point in the history
… compressing chat area
  • Loading branch information
clone1018 committed Mar 18, 2022
1 parent bc86a58 commit 36eb27d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
7 changes: 3 additions & 4 deletions lib/components/Chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class ChatMessages extends StatelessWidget {
itemCount: state.messages.length,
shrinkWrap: true,
reverse: true,
padding: EdgeInsets.only(top: 10, bottom: 10),
physics: BouncingScrollPhysics(),
itemBuilder: (context, index) {
return _buildChatMessage(context, state.messages[index]);
Expand All @@ -110,15 +109,15 @@ class ChatMessages extends StatelessWidget {

Widget _buildChatMessage(BuildContext context, ChatMessage message) {
return Container(
padding: EdgeInsets.all(3),
padding: EdgeInsets.all(2),
child: Align(
alignment: Alignment.topLeft,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: Theme.of(context).brightness == Brightness.dark
? Color(0xFF0E1826)
: Colors.white70,
? Color(0xFF0E1826).withOpacity(0.90)
: Colors.white.withOpacity(0.90),
),
padding: EdgeInsets.all(10),
child: Text.rich(
Expand Down
10 changes: 5 additions & 5 deletions lib/components/MatureWarning.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ class MatureWarning extends StatelessWidget {
children: [
Text(
context.t("Mature Content Warning"),
style: Theme.of(context).textTheme.headline4,
style: Theme.of(context).textTheme.headline5,
textAlign: TextAlign.center,
),
Text(
context.t(
"The streamer has flagged this channel as only appropriate for Mature Audiences."),
style: Theme.of(context).textTheme.subtitle1,
textAlign: TextAlign.center,
),
Padding(padding: EdgeInsets.only(top: 10)),
Text(
context.t("Do you wish to continue?"),
style: Theme.of(context).textTheme.subtitle1,
textAlign: TextAlign.center,
),
Padding(
child: OutlinedButton(
Expand All @@ -32,10 +36,6 @@ class MatureWarning extends StatelessWidget {
),
padding: EdgeInsets.symmetric(vertical: 8),
),
ElevatedButton(
child: Text(context.t("Go Back")),
onPressed: () => Navigator.pop(context),
)
],
));
}
Expand Down
29 changes: 21 additions & 8 deletions lib/screens/ChannelScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,26 @@ class ChannelScreen extends StatelessWidget {
if (state is ChannelLoading) {
return Scaffold(
body: SafeArea(
child: _backButtonContainer(context, Loading(context.t("Loading Stream"))),
child: _backButtonContainer(
context, Loading(context.t("Loading Stream"))),
),
);
}

if (state is ChannelShowMatureWarning) {
return Scaffold(
body: SafeArea(
child: MatureWarning(onAccept: () {
context
.read<ChannelBloc>()
.add(WatchChannel(channelId: channel.id));
}),
child: _backButtonContainer(
context,
MatureWarning(
onAccept: () {
context
.read<ChannelBloc>()
.add(WatchChannel(channelId: channel.id));
},
),
darken: true,
),
),
);
}
Expand Down Expand Up @@ -105,7 +112,13 @@ class ChannelScreen extends StatelessWidget {
});
}

Widget _backButtonContainer(BuildContext context, Widget child) {
Widget _backButtonContainer(BuildContext context, Widget child,
{bool darken = false}) {
// On dark mode, there's no point in darkening it
if (Theme.of(context).brightness == Brightness.dark) {
darken = false;
}

return Stack(
children: [
child,
Expand All @@ -114,7 +127,7 @@ class ChannelScreen extends StatelessWidget {
padding: EdgeInsets.all(5),
child: Icon(
Icons.chevron_left,
color: Colors.white70,
color: darken ? Colors.black87 : Colors.white70,
),
),
onTap: () => Navigator.pop(context),
Expand Down

0 comments on commit 36eb27d

Please sign in to comment.