🐛 Fix platform specific bugs & crashes

This commit is contained in:
LittleSheep 2024-10-06 01:42:51 +08:00
parent 9c3d181deb
commit 60033fdef3
7 changed files with 85 additions and 60 deletions

View File

@ -29,6 +29,8 @@ abstract class PlatformInfo {
static bool get canRateTheApp => isIOS || isMacOS;
static bool get canCropImage => isIOS || isAndroid || isWeb;
static bool get canRecord => (isMobile || isMacOS);
static bool get canPushNotification => isAndroid || isIOS || isMacOS;

View File

@ -1,5 +1,3 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:gap/gap.dart';
@ -9,6 +7,7 @@ import 'package:image_picker/image_picker.dart';
import 'package:intl/intl.dart';
import 'package:solian/exts.dart';
import 'package:solian/models/attachment.dart';
import 'package:solian/platform.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/providers/content/attachment.dart';
import 'package:solian/services.dart';
@ -77,9 +76,12 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
final AuthProvider auth = Get.find();
if (auth.isAuthorized.isFalse) return;
XFile file;
final image = await _imagePicker.pickImage(source: ImageSource.gallery);
if (image == null) return;
if (PlatformInfo.canCropImage) {
CroppedFile? croppedFile = await ImageCropper().cropImage(
sourcePath: image.path,
uiSettings: [
@ -106,7 +108,10 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
);
if (croppedFile == null) return;
final file = File(croppedFile.path);
file = XFile(croppedFile.path);
} else {
file = XFile(image.path);
}
setState(() => _isBusy = true);

View File

@ -289,7 +289,7 @@ class _ChatListState extends State<ChatList> {
..._realmChannels.values.expand((x) => x),
]),
selfId: selfId,
useReplace: false,
useReplace: AppTheme.isLargeScreen(context),
),
),
RefreshIndicator(
@ -297,7 +297,7 @@ class _ChatListState extends State<ChatList> {
child: ChannelListWidget(
channels: _directChannels,
selfId: selfId,
useReplace: false,
useReplace: AppTheme.isLargeScreen(context),
),
),
...realms.availableRealms.map(
@ -306,7 +306,7 @@ class _ChatListState extends State<ChatList> {
child: ChannelListWidget(
channels: _realmChannels[x.alias] ?? [],
selfId: selfId,
useReplace: false,
useReplace: AppTheme.isLargeScreen(context),
),
),
),

View File

@ -1,5 +1,3 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:get/get.dart';
@ -8,6 +6,7 @@ import 'package:image_picker/image_picker.dart';
import 'package:solian/exts.dart';
import 'package:solian/models/attachment.dart';
import 'package:solian/models/realm.dart';
import 'package:solian/platform.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/providers/content/attachment.dart';
import 'package:solian/router.dart';
@ -84,9 +83,12 @@ class _RealmOrganizeScreenState extends State<RealmOrganizeScreen> {
final AuthProvider auth = Get.find();
if (auth.isAuthorized.isFalse) return;
XFile file;
final image = await _imagePicker.pickImage(source: ImageSource.gallery);
if (image == null) return;
if (PlatformInfo.canCropImage) {
CroppedFile? croppedFile = await ImageCropper().cropImage(
sourcePath: image.path,
uiSettings: [
@ -113,7 +115,10 @@ class _RealmOrganizeScreenState extends State<RealmOrganizeScreen> {
);
if (croppedFile == null) return;
final file = File(croppedFile.path);
file = XFile(croppedFile.path);
} else {
file = XFile(image.path);
}
setState(() => _isBusy = true);

View File

@ -396,7 +396,8 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
),
if (!element.isCompleted &&
element.error == null &&
canBeCrop)
canBeCrop &&
PlatformInfo.canCropImage)
Obx(
() => IconButton(
color: Colors.teal,

View File

@ -1,4 +1,7 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:solian/router.dart';
import 'package:solian/widgets/navigation/app_navigation.dart';
@ -54,6 +57,9 @@ class _AppNavigationRailState extends State<AppNavigationRail> {
setState(() => _currentIndex = idx);
AppRouter.instance.goNamed(AppNavigation.destinations[idx].page);
},
).paddingOnly(
top: max(16, MediaQuery.of(context).padding.top),
bottom: max(16, MediaQuery.of(context).padding.bottom),
);
}
}

View File

@ -57,5 +57,11 @@
<string>INStartCallIntent</string>
<string>INSendMessageIntent</string>
</array>
<key>NSCameraUsageDescription</key>
<string>Allow you take photo/video for your message or post</string>
<key>NSMicrophoneUsageDescription</key>
<string>Allow you record audio for your message or post</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Allow you add photo to your message or post</string>
</dict>
</plist>