Fix Dart CardThemeData and modern receive_sharing_intent 1.8 API, pin androidx.activity

This commit is contained in:
Chris 2026-11-01 15:31:42 -05:00
parent e2b9f0d9ba
commit e6ca9b3efc
5 changed files with 54 additions and 74 deletions

View file

@ -12,15 +12,8 @@ if (localPropertiesFile.exists()) {
} }
} }
def flutterVersionCode = localProperties.getProperty('flutter.versionCode') def flutterVersionCode = localProperties.getProperty('flutter.versionCode') ?: '1'
if (flutterVersionCode == null) { def flutterVersionName = localProperties.getProperty('flutter.versionName') ?: '1.0'
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
android { android {
namespace "com.forkfolio.mobile" namespace "com.forkfolio.mobile"
@ -57,6 +50,15 @@ android {
} }
} }
configurations.all {
resolutionStrategy {
force 'androidx.activity:activity:1.9.3'
force 'androidx.activity:activity-ktx:1.9.3'
force 'androidx.core:core:1.15.0'
force 'androidx.core:core-ktx:1.15.0'
}
}
flutter { flutter {
source '../..' source '../..'
} }

View file

@ -13,18 +13,6 @@ subprojects {
project.evaluationDependsOn(':app') project.evaluationDependsOn(':app')
} }
subprojects { project ->
if (project.name != 'app') {
project.afterEvaluate {
if (project.hasProperty('android')) {
project.android {
compileSdkVersion 35
}
}
}
}
}
tasks.register("clean", Delete) { tasks.register("clean", Delete) {
delete rootProject.buildDir delete rootProject.buildDir
} }

View file

@ -37,7 +37,7 @@ class AppTheme {
letterSpacing: -0.3, letterSpacing: -0.3,
), ),
), ),
cardTheme: CardTheme( cardTheme: CardThemeData(
color: surface, color: surface,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14), borderRadius: BorderRadius.circular(14),

View file

@ -7,68 +7,59 @@ class ShareReceiverService {
StreamSubscription? _intentSub; StreamSubscription? _intentSub;
void init(BuildContext context) { void init(BuildContext context) {
// 1. Listen to shared text/links while app is in memory // 1. Listen to shared media/text while app is in memory
_intentSub = ReceiveSharingIntent.getTextStream().listen((String value) { _intentSub = ReceiveSharingIntent.instance.getMediaStream().listen((List<SharedMediaFile> value) {
if (value.isNotEmpty) { if (value.isNotEmpty) {
_handleSharedText(context, value); _handleSharedMedia(context, value);
} }
}, onError: (err) { }, onError: (err) {
debugPrint("getLinkStream error: $err"); debugPrint("getMediaStream error: $err");
}); });
// 2. Get the shared text/link when the app is launched from closed state // 2. Get the shared media/text when the app is launched from closed state
ReceiveSharingIntent.getInitialText().then((String? value) { ReceiveSharingIntent.instance.getInitialMedia().then((List<SharedMediaFile> value) {
if (value != null && value.isNotEmpty) {
_handleSharedText(context, value);
}
});
// 3. Listen to shared files/images (e.g. sharing photo from Gallery)
ReceiveSharingIntent.getImageStream().listen((List<SharedMediaFile> value) {
if (value.isNotEmpty) { if (value.isNotEmpty) {
_handleSharedFiles(context, value); _handleSharedMedia(context, value);
}
}, onError: (err) {
debugPrint("getImageStream error: $err");
});
ReceiveSharingIntent.getInitialImage().then((List<SharedMediaFile> value) {
if (value.isNotEmpty) {
_handleSharedFiles(context, value);
} }
}); });
} }
void _handleSharedText(BuildContext context, String rawText) { void _handleSharedMedia(BuildContext context, List<SharedMediaFile> files) {
// Sanitize and extract URL from messy text (e.g. Instagram caption + link)
final urlRegex = RegExp(r'https?://[^\s]+');
final match = urlRegex.firstMatch(rawText);
final url = match?.group(0);
final rawCaption = rawText.replaceFirst(url ?? '', '').trim();
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (ctx) => QuickShareSheet(
url: url,
rawCaption: rawCaption.isNotEmpty ? rawCaption : null,
),
);
}
void _handleSharedFiles(BuildContext context, List<SharedMediaFile> files) {
if (files.isEmpty) return; if (files.isEmpty) return;
final firstFile = files.first;
showModalBottomSheet( for (final file in files) {
context: context, final path = file.path;
isScrollControlled: true, if (path.isEmpty) continue;
backgroundColor: Colors.transparent,
builder: (ctx) => QuickShareSheet( // Check if it's an image file
imagePath: firstFile.path, final lower = path.toLowerCase();
), if (file.type == SharedMediaType.image || lower.endsWith('.jpg') || lower.endsWith('.png') || lower.endsWith('.jpeg') || lower.endsWith('.webp')) {
); showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (ctx) => QuickShareSheet(imagePath: path),
);
return;
}
// Otherwise it's shared text or URL
final urlRegex = RegExp(r'https?://[^\s]+');
final match = urlRegex.firstMatch(path);
final url = match?.group(0);
final rawCaption = path.replaceFirst(url ?? '', '').trim();
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (ctx) => QuickShareSheet(
url: url,
rawCaption: rawCaption.isNotEmpty ? rawCaption : null,
),
);
return;
}
} }
void dispose() { void dispose() {

View file

@ -21,12 +21,11 @@ dependencies:
flutter_secure_storage: ^9.2.2 flutter_secure_storage: ^9.2.2
# Share Target (Android ACTION_SEND & iOS Share Extension) # Share Target (Android ACTION_SEND & iOS Share Extension)
receive_sharing_intent: ^1.4.5 receive_sharing_intent: ^1.8.1
# Camera & Image Ingestion for Cookbook OCR # Camera & Image Ingestion for Cookbook OCR
camera: ^0.10.5+9 camera: ^0.10.5+9
image_picker: ^1.1.1 image_picker: ^1.1.1
image_cropper: ^5.0.1
# Cook Mode (Keep screen awake while hands are messy) # Cook Mode (Keep screen awake while hands are messy)
wakelock_plus: ^1.2.5 wakelock_plus: ^1.2.5