Skip to content

Commit

Permalink
fix offline webview. (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
Livinglist authored Nov 3, 2023
1 parent 939d55e commit 109b928
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
4 changes: 4 additions & 0 deletions lib/extensions/context_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,8 @@ extension ContextExtension on BuildContext {
int get storyTileMaxLines {
return _storyTileMaxLines;
}

double get topPadding {
return MediaQuery.of(this).padding.top + kToolbarHeight;
}
}
6 changes: 2 additions & 4 deletions lib/screens/item/item_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@ class _ItemScreenState extends State<ItemScreen>

@override
Widget build(BuildContext context) {
final double topPadding =
MediaQuery.of(context).padding.top + kToolbarHeight;
return BlocBuilder<AuthBloc, AuthState>(
builder: (BuildContext context, AuthState authState) {
return MultiBlocListener(
Expand Down Expand Up @@ -273,7 +271,7 @@ class _ItemScreenState extends State<ItemScreen>
scrollOffsetListener: scrollOffsetListener,
commentEditingController: commentEditingController,
authState: authState,
topPadding: topPadding,
topPadding: context.topPadding,
splitViewEnabled: widget.splitViewEnabled,
onMoreTapped: onMoreTapped,
onRightMoreTapped: onRightMoreTapped,
Expand Down Expand Up @@ -347,7 +345,7 @@ class _ItemScreenState extends State<ItemScreen>
scrollOffsetListener: scrollOffsetListener,
commentEditingController: commentEditingController,
authState: authState,
topPadding: topPadding,
topPadding: context.topPadding,
splitViewEnabled: widget.splitViewEnabled,
onMoreTapped: onMoreTapped,
onRightMoreTapped: onRightMoreTapped,
Expand Down
24 changes: 18 additions & 6 deletions lib/screens/web_view/web_view_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class WebViewScreen extends StatefulWidget {

class _WebViewScreenState extends State<WebViewScreen> {
final WebViewController controller = WebViewController();
bool showFullUrl = false;

@override
void initState() {
Expand All @@ -43,15 +44,26 @@ class _WebViewScreenState extends State<WebViewScreen> {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).canvasColor,
title: Text(
humanize(widget.url),
style: const TextStyle(
fontSize: TextDimens.pt12,
foregroundColor: Theme.of(context).colorScheme.onSurface,
title: GestureDetector(
onTap: () {
setState(() {
showFullUrl = !showFullUrl;
});
},
child: Text(
showFullUrl
? humanize(widget.url)
: Uri.parse(widget.url).authority,
style: const TextStyle(
fontSize: TextDimens.pt14,
),
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
),
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
),
centerTitle: true,
elevation: 0,
),
body: WebViewWidget(
controller: controller,
Expand Down
1 change: 1 addition & 0 deletions lib/screens/widgets/offline_banner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class OfflineBanner extends StatelessWidget {
builder: (BuildContext context, StoriesState state) {
if (state.isOfflineReading) {
return MaterialBanner(
dividerColor: Palette.transparent,
content: Text(
'You are currently in offline mode. '
'${showExitButton ? 'Exit to fetch latest stories.' : ''}',
Expand Down

0 comments on commit 109b928

Please sign in to comment.