Skip to content

Commit

Permalink
Adapt to the immersive status bar and navigation bar of the mobile ve…
Browse files Browse the repository at this point in the history
…rsion
  • Loading branch information
LcJuves committed Dec 13, 2024
1 parent f6afc7d commit 4550fd2
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 24 deletions.
15 changes: 15 additions & 0 deletions lib/constants.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

abstract final class Constants {
static const Color themeColor = Color(0xFF1E1E1E);
static const SystemUiOverlayStyle defaultSystemUiOverlayStyle =
SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.light,
statusBarBrightness: Brightness.light,
systemNavigationBarColor: Constants.themeColor,
systemNavigationBarContrastEnforced: false,
systemNavigationBarIconBrightness: Brightness.light,
systemStatusBarContrastEnforced: false);
}
15 changes: 0 additions & 15 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'page/home_page.dart';

void main() {
if (!kIsWeb && Platform.isAndroid) {
SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(
// statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.light,
statusBarBrightness: Brightness.light,
systemNavigationBarColor: Color.fromARGB(255, 30, 30, 30),
systemNavigationBarContrastEnforced: true,
systemNavigationBarIconBrightness: Brightness.light,
);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
runApp(const MyApp());
}

Expand Down
15 changes: 12 additions & 3 deletions lib/page/client_preview_book_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:internet_file/internet_file.dart';
import 'package:odb/constants.dart';
import 'package:pdfx/pdfx.dart';

// ignore: must_be_immutable
Expand Down Expand Up @@ -41,15 +42,23 @@ class _ClientPreviewBookPageState extends State<ClientPreviewBookPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey,
backgroundColor: Colors.white,
appBar: AppBar(
leading: IconButton(
onPressed: () async => await Navigator.maybePop(context),
icon: const Icon(Icons.arrow_back_rounded)),
systemOverlayStyle: Constants.defaultSystemUiOverlayStyle.copyWith(
statusBarIconBrightness: Brightness.dark,
systemNavigationBarColor: Colors.white,
systemNavigationBarIconBrightness: Brightness.light,
),
title: Text(
widget._title,
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
),
actions: <Widget>[
IconButton(
icon: const Icon(Icons.navigate_before),
icon: const Icon(Icons.navigate_before_rounded),
onPressed: () {
_pdfController.previousPage(
curve: Curves.ease,
Expand All @@ -68,7 +77,7 @@ class _ClientPreviewBookPageState extends State<ClientPreviewBookPage> {
),
),
IconButton(
icon: const Icon(Icons.navigate_next),
icon: const Icon(Icons.navigate_next_rounded),
onPressed: () {
_pdfController.nextPage(
curve: Curves.ease,
Expand Down
11 changes: 7 additions & 4 deletions lib/page/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:odb/constants.dart';
import 'package:protobuffers/books.pb.dart';

import '../widget/book_item_widget.dart';
Expand All @@ -13,10 +14,12 @@ class HomePage extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
title: const TitleBar(),
),
backgroundColor: const Color.fromARGB(255, 30, 30, 30),
backgroundColor: Colors.transparent,
surfaceTintColor: Constants.themeColor,
scrolledUnderElevation: 10,
title: const TitleBar(),
systemOverlayStyle: Constants.defaultSystemUiOverlayStyle),
backgroundColor: Constants.themeColor,
body: const BooksContainer(),
bottomNavigationBar: const SafeArea(child: BottomText()),
);
Expand Down
4 changes: 2 additions & 2 deletions lib/widget/book_item_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:odb/webspec.dart';
// import 'package:odb/webspec.dart';
import 'package:url_launcher/url_launcher.dart';

import '../page/client_preview_book_page.dart';
Expand Down Expand Up @@ -33,7 +33,7 @@ class BookItemWidget extends StatelessWidget {
const prefixUrl = "https://files.lcjuves.com";
final url = "$prefixUrl/pdf/${item.name}";
if (kIsWeb) {
await webLoadAnimationAndLaunch(url);
// await webLoadAnimationAndLaunch(url);
} else if (!Platform.isLinux && !Platform.isWindows) {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => ClientPreviewBookPage(previewUrl: url),
Expand Down

0 comments on commit 4550fd2

Please sign in to comment.