Skip to content

Commit

Permalink
Better code organization
Browse files Browse the repository at this point in the history
  • Loading branch information
LcJuves committed Dec 9, 2024
1 parent 95c7cda commit b2792b9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 9 additions & 0 deletions lib/webspec.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'package:web/web.dart' as web;

Future<void> loadAnimationAndLaunch(String url) async {
var elem = web.document.querySelector(".content") as web.HTMLDivElement?;
elem?.style.display = 'flex';
web.window.location.replace(url);
await Future.delayed(
const Duration(seconds: 6), () => elem?.style.display = 'flex');
}
9 changes: 2 additions & 7 deletions lib/widget/book_item_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ 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:url_launcher/url_launcher.dart';
import 'package:web/web.dart' as web;

import '../page/client_preview_book_page.dart';
import '../page/windows_preview_book_page.dart';
Expand Down Expand Up @@ -33,12 +33,7 @@ class BookItemWidget extends StatelessWidget {
const prefixUrl = "https://files.lcjuves.com";
final url = "$prefixUrl/pdf/${item.name}";
if (kIsWeb) {
var elem =
web.document.querySelector(".content") as web.HTMLDivElement?;
elem?.style.display = 'flex';
web.window.location.replace(url);
await Future.delayed(
const Duration(seconds: 6), () => elem?.style.display = 'flex');
await loadAnimationAndLaunch(url);
} else if (!Platform.isLinux && !Platform.isWindows) {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => ClientPreviewBookPage(previewUrl: url),
Expand Down

0 comments on commit b2792b9

Please sign in to comment.