-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e07395
commit 3e9ad95
Showing
7 changed files
with
70 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// This source code is a part of Project Violet. | ||
// Copyright (C) 2020-2023. violet-team. Licensed under the Apache-2.0 License. | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:violet/component/hentai.dart'; | ||
import 'package:violet/database/user/bookmark.dart'; | ||
import 'package:violet/model/article_info.dart'; | ||
import 'package:violet/pages/article_info/article_info_page.dart'; | ||
import 'package:violet/widgets/article_item/image_provider_manager.dart'; | ||
|
||
// TODO: expand using optional arguments | ||
Future showArticleInfo(BuildContext context, int id) async { | ||
final height = MediaQuery.of(context).size.height; | ||
|
||
final search = await HentaiManager.idSearch(id.toString()); | ||
if (search.results.length != 1) return; | ||
|
||
final qr = search.results.first; | ||
|
||
HentaiManager.getImageProvider(qr).then((value) async { | ||
final thumbnail = await value.getThumbnailUrl(); | ||
final headers = await value.getHeader(0); | ||
ProviderManager.insert(qr.id(), value); | ||
|
||
final isBookmarked = | ||
await (await Bookmark.getInstance()).isBookmark(qr.id()); | ||
|
||
Provider<ArticleInfo>? cache; | ||
showModalBottomSheet( | ||
context: context, | ||
isScrollControlled: true, | ||
builder: (_) { | ||
return DraggableScrollableSheet( | ||
initialChildSize: 400 / height, | ||
minChildSize: 400 / height, | ||
maxChildSize: 0.9, | ||
expand: false, | ||
builder: (_, controller) { | ||
cache ??= Provider<ArticleInfo>.value( | ||
value: ArticleInfo.fromArticleInfo( | ||
queryResult: qr, | ||
thumbnail: thumbnail, | ||
headers: headers, | ||
heroKey: 'zxcvzxcvzxcv', | ||
isBookmarked: isBookmarked, | ||
controller: controller, | ||
), | ||
child: const ArticleInfoPage( | ||
key: ObjectKey('asdfasdf'), | ||
), | ||
); | ||
return cache!; | ||
}, | ||
); | ||
}, | ||
); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.