From 1aabe1acba9f87e44ec0069ad25f09bc811ab7df Mon Sep 17 00:00:00 2001 From: poppingmoon <63451158+poppingmoon@users.noreply.github.com> Date: Tue, 3 Oct 2023 08:24:51 +0900 Subject: [PATCH] =?UTF-8?q?=E7=94=BB=E5=83=8F=E4=BB=A5=E5=A4=96=E3=81=AE?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=82=E3=82=A2=E3=83=83?= =?UTF-8?q?=E3=83=97=E3=83=AD=E3=83=BC=E3=83=89=E3=81=A7=E3=81=8D=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../note_create_state_notifier.dart | 5 +--- .../note_create_page/create_file_view.dart | 18 +++++++-------- .../drive_file_select_dialog.dart | 23 ++++++++----------- 3 files changed, 18 insertions(+), 28 deletions(-) diff --git a/lib/state_notifier/note_create_page/note_create_state_notifier.dart b/lib/state_notifier/note_create_page/note_create_state_notifier.dart index fa228b5a2..44260a84d 100644 --- a/lib/state_notifier/note_create_page/note_create_state_notifier.dart +++ b/lib/state_notifier/note_create_page/note_create_state_notifier.dart @@ -462,10 +462,7 @@ class NoteCreateNotifier extends StateNotifier { ], ); } else if (result == DriveModalSheetReturnValue.upload) { - final result = await FilePicker.platform.pickFiles( - type: FileType.image, - allowMultiple: true, - ); + final result = await FilePicker.platform.pickFiles(allowMultiple: true); if (result == null || result.files.isEmpty) return; final files = result.files.map((file) { diff --git a/lib/view/note_create_page/create_file_view.dart b/lib/view/note_create_page/create_file_view.dart index 56efd7067..c26386542 100644 --- a/lib/view/note_create_page/create_file_view.dart +++ b/lib/view/note_create_page/create_file_view.dart @@ -1,5 +1,3 @@ -import 'dart:typed_data'; - import 'package:auto_route/auto_route.dart'; import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart'; @@ -9,8 +7,8 @@ import 'package:miria/model/misskey_post_file.dart'; import 'package:miria/providers.dart'; import 'package:miria/router/app_router.dart'; import 'package:miria/view/common/account_scope.dart'; -import 'package:miria/view/common/misskey_notes/network_image.dart'; import 'package:miria/view/note_create_page/file_settings_dialog.dart'; +import 'package:miria/view/note_create_page/thumbnail.dart'; class CreateFileView extends ConsumerWidget { final int index; @@ -71,29 +69,29 @@ class CreateFileView extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { + final type = file.type; + final isImage = file.type?.startsWith("image") ?? false; return Column( children: [ SizedBox( height: 200, child: GestureDetector( - onTap: (file.type?.startsWith("image") ?? false) && + onTap: isImage && (defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.macOS || defaultTargetPlatform == TargetPlatform.android) ? () => onTap(context, ref) : null, child: switch (file) { - PostFile(:final file) => Image.file(file), - AlreadyPostedFile(:final file) => NetworkImageView( - url: file.thumbnailUrl ?? file.url, - type: ImageType.imageThumbnail, - ), + PostFile(:final file) => + isImage ? Image.file(file) : Thumbnail(type: type), + AlreadyPostedFile(:final file) => Thumbnail.driveFile(file), }, ), ), Row( children: [ - if (file.isNsfw) const Icon(Icons.details_rounded), + if (file.isNsfw) const Icon(Icons.warning_amber), Text(file.fileName), IconButton( onPressed: () => detailTap(context, ref), diff --git a/lib/view/note_create_page/drive_file_select_dialog.dart b/lib/view/note_create_page/drive_file_select_dialog.dart index 8b51bdbe3..b3ded42e5 100644 --- a/lib/view/note_create_page/drive_file_select_dialog.dart +++ b/lib/view/note_create_page/drive_file_select_dialog.dart @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:miria/model/account.dart'; import 'package:miria/providers.dart'; -import 'package:miria/view/common/misskey_notes/network_image.dart'; import 'package:miria/view/common/pushable_listview.dart'; +import 'package:miria/view/note_create_page/thumbnail.dart'; import 'package:miria/view/themes/app_theme.dart'; import 'package:misskey_dart/misskey_dart.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; @@ -156,19 +156,14 @@ class DriveFileSelectDialogState extends ConsumerState { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - SizedBox( - width: double.infinity, - height: 200, - child: item.thumbnailUrl == null - ? const SizedBox.shrink() - : ClipRRect( - borderRadius: BorderRadius.circular(5), - child: NetworkImageView( - fit: BoxFit.cover, - url: item.thumbnailUrl!, - type: ImageType.imageThumbnail, - ), - ), + ClipRRect( + borderRadius: BorderRadius.circular(5), + child: Thumbnail.driveFile( + item, + width: double.infinity, + height: 200, + fit: BoxFit.cover, + ), ), Text(item.name), ],