Skip to content

Commit

Permalink
Feat: ThumbnailListView
Browse files Browse the repository at this point in the history
  • Loading branch information
honjow committed Jul 28, 2021
1 parent c47c019 commit e759a3b
Show file tree
Hide file tree
Showing 6 changed files with 339 additions and 136 deletions.
3 changes: 0 additions & 3 deletions lib/pages/gallery/controller/gallery_page_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,6 @@ class GalleryPageController extends GetxController
refresh: isRefresh, // 刷新画廊后加载缩略图不能从缓存读取,否则在改变每页数量后加载画廊会出错
);

// logger.v(
// '添加的图片序号: ${_moreImageList.map((GalleryPreview e) => e.ser).join(',')}');

addAllImages(_moreImageList);
if (Get.isRegistered<AllPreviewsPageController>()) {
Get.find<AllPreviewsPageController>().update();
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/gallery/view/comment_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ class CommentItem extends StatelessWidget {

final TextStyle _commentTextStyle = TextStyle(
fontSize: 14,
height: 1.2,
color: CupertinoDynamicColor.resolve(ThemeColors.commitText, context),
fontFamilyFallback: EHConst.fontFamilyFallback,
);
Expand Down Expand Up @@ -356,6 +357,7 @@ class CommentItem extends StatelessWidget {
style: style ??
TextStyle(
fontSize: 13,
height: 1.2,
color: CupertinoDynamicColor.resolve(
ThemeColors.commitText, context),
fontFamilyFallback: EHConst.fontFamilyFallback,
Expand Down
57 changes: 46 additions & 11 deletions lib/pages/image_view_ext/controller/view_ext_contorller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,19 @@ import 'view_ext_state.dart';

const double kBottomBarHeight = 44.0;
const double kTopBarHeight = 44.0;

const String idViewTopBar = 'ViewExtController.ViewTopBar';
const String idViewBottomBar = 'ViewExtController.ViewBottomBar';
const String idViewBar = 'ViewExtController.ViewBar';
const String idViewPageSlider = 'ViewExtController.ViewPageSlider';
const String idSlidePage = 'ViewExtController.ViewImageSlidePage';
const String idImagePageView = 'ViewExtController.ImagePageView';
const String idImageListView = 'ViewExtController.ImageListView';
const String idViewColumnModeIcon = 'ViewExtController.ViewColumnModeIcon';
const String idAutoReadIcon = 'ViewExtController.AutoReadIcon';
const double kThumbListViewHeight = 140.0;

const String idViewTopBar = 'ViewTopBar';
const String idViewBottomBar = 'ViewBottomBar';
const String idViewBar = 'ViewBar';
const String idViewPageSlider = 'ViewPageSlider';
const String idSlidePage = 'ViewImageSlidePage';
const String idImagePageView = 'ImagePageView';
const String idImageListView = 'ImageListView';
const String idViewColumnModeIcon = 'ViewColumnModeIcon';
const String idThumbnailListView = 'ThumbnailListView';
const String idShowThumbListIcon = 'ShowThumbListIcon';
const String idAutoReadIcon = 'AutoReadIcon';

/// 支持在线以及本地(已下载)阅读的组件
class ViewExtController extends GetxController {
Expand Down Expand Up @@ -216,6 +219,35 @@ class ViewExtController extends GetxController {
pageController.jumpToPage(_toIndex);
}

Future<void> switchShowThumbList() async {
if (vState.showThumbList) {
vState.showThumbList = false;
} else {
vState.showThumbList = true;
}

update([idShowThumbListIcon, idViewBottomBar, idThumbnailListView]);
}

/// 拉取图片信息
Future<GalleryImage?> fetchThumb(
int itemSer, {
bool refresh = false,
bool changeSource = false,
}) async {
final GalleryImage? tImage = _galleryPageController.imageMap[itemSer];
if (tImage == null) {
logger.d('ser:$itemSer 所在页尚未获取, 开始获取');

// 直接获取需要的ser所在页
await _galleryPageController.loadImagesForSer(itemSer);
}

final GalleryImage? image = _galleryPageController.imageMap[itemSer];

return image;
}

/// 拉取图片信息
Future<GalleryImage?> fetchImage(
int itemSer, {
Expand Down Expand Up @@ -362,8 +394,11 @@ class ViewExtController extends GetxController {
}

void handOnSliderChangedEnd(double value) {
vState.currentItemIndex = value.round();
jumpToPage(value.round());
}

void jumpToPage(int index) {
vState.currentItemIndex = index;
if (vState.viewMode != ViewMode.topToBottom) {
pageController.jumpToPage(vState.pageIndex);
} else {
Expand Down
9 changes: 6 additions & 3 deletions lib/pages/image_view_ext/controller/view_ext_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,15 @@ class ViewExtState {
/// 显示Bar
bool showBar = false;

/// 底栏高度
double bottomBarHeight = 0.0;

/// 底栏偏移
double get bottomBarOffset {
final _paddingBottom = Get.context!.mediaQueryPadding.bottom;

if (showBar) {
return 0;
} else {
return -kBottomBarHeight * 2 - _paddingBottom;
return -bottomBarHeight;
}
}

Expand Down Expand Up @@ -178,4 +179,6 @@ class ViewExtState {

bool conditionItemIndex = true;
int tempIndex = 0;

bool showThumbList = false;
}
Loading

0 comments on commit e759a3b

Please sign in to comment.