Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Shrink image sizes of attachments in Reply app. #996

Merged
merged 7 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/studies/reply/mail_card_preview.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:animations/animations.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:gallery/layout/adaptive.dart';
import 'package:gallery/studies/reply/colors.dart';
Expand Down Expand Up @@ -255,6 +256,16 @@ class _MailPreview extends StatelessWidget {
class _PicturePreview extends StatelessWidget {
const _PicturePreview();

bool _shouldShrinkImage() {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
case TargetPlatform.android:
return true;
default:
return false;
}
}

@override
Widget build(BuildContext context) {
return SizedBox(
Expand All @@ -269,6 +280,7 @@ class _PicturePreview extends StatelessWidget {
'reply/attachments/paris_${index + 1}.jpg',
gaplessPlayback: true,
package: 'flutter_gallery_assets',
cacheWidth: _shouldShrinkImage() ? 200 : null,
),
);
},
Expand Down
12 changes: 12 additions & 0 deletions lib/studies/reply/mail_view_page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:gallery/studies/reply/model/email_model.dart';
import 'package:gallery/studies/reply/model/email_store.dart';
Expand Down Expand Up @@ -134,6 +135,16 @@ class _MailViewBody extends StatelessWidget {
class _PictureGrid extends StatelessWidget {
const _PictureGrid();

bool _shouldShrinkImage() {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
case TargetPlatform.android:
return true;
default:
return false;
}
}

@override
Widget build(BuildContext context) {
return GridView.builder(
Expand All @@ -151,6 +162,7 @@ class _PictureGrid extends StatelessWidget {
gaplessPlayback: true,
package: 'flutter_gallery_assets',
fit: BoxFit.fill,
cacheWidth: _shouldShrinkImage() ? 500 : null,
);
},
);
Expand Down
1 change: 1 addition & 0 deletions lib/studies/shrine/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class _ShrineAppState extends State<ShrineApp>

return ScopedModel<AppStateModel>(
model: _model.value,
// ignore: deprecated_member_use
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think this should be updated now because the framework change has not made it to g3 yet (and it had to be reverted once)

child: WillPopScope(
onWillPop: _onWillPop,
child: MaterialApp(
Expand Down
Loading