🗑️ Clean unused code
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_eval/flutter_eval.dart';
|
||||
|
||||
class DartMiniappDisplay extends StatelessWidget {
|
||||
final String package;
|
||||
final String sourceCode;
|
||||
|
||||
const DartMiniappDisplay({
|
||||
super.key,
|
||||
required this.package,
|
||||
required this.sourceCode,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return EvalWidget(
|
||||
packages: {
|
||||
package: {'main.dart': sourceCode},
|
||||
},
|
||||
library: 'package:$package/main.dart',
|
||||
function: 'buildEntry',
|
||||
args: [],
|
||||
assetPath: 'assets/$package/main.evc',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,14 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:island/modular/miniapp_loader.dart';
|
||||
import 'package:island/pods/message.dart';
|
||||
import 'package:island/pods/network.dart';
|
||||
import 'package:island/pods/modular/plugin_registry.dart';
|
||||
import 'package:island/services/update_service.dart';
|
||||
import 'package:island/widgets/alert.dart';
|
||||
import 'package:island/widgets/content/network_status_sheet.dart';
|
||||
import 'package:island/widgets/content/sheet.dart';
|
||||
import 'package:island/widgets/miniapp_modal.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
import 'package:island/pods/config.dart';
|
||||
import 'package:talker_flutter/talker_flutter.dart';
|
||||
@@ -28,7 +22,7 @@ Future<void> _showSetTokenDialog(BuildContext context, WidgetRef ref) async {
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Set Access Token'),
|
||||
title: const Text('Set access token'),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
decoration: const InputDecoration(
|
||||
@@ -139,7 +133,7 @@ class DebugSheet extends HookConsumerWidget {
|
||||
leading: const Icon(Symbols.error),
|
||||
trailing: const Icon(Symbols.chevron_right),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
title: const Text('Test Error Alert'),
|
||||
title: const Text('Test error alert'),
|
||||
onTap: () {
|
||||
showErrorAlert(
|
||||
'This is a test error message for debugging purposes.',
|
||||
@@ -151,7 +145,7 @@ class DebugSheet extends HookConsumerWidget {
|
||||
leading: const Icon(Symbols.info),
|
||||
trailing: const Icon(Symbols.chevron_right),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
title: const Text('Test Info Alert'),
|
||||
title: const Text('Test info alert'),
|
||||
onTap: () {
|
||||
showInfoAlert(
|
||||
'This is a test info message for debugging purposes.',
|
||||
@@ -202,136 +196,9 @@ class DebugSheet extends HookConsumerWidget {
|
||||
DefaultCacheManager().emptyCache();
|
||||
},
|
||||
),
|
||||
const Divider(height: 8),
|
||||
if (!kIsWeb &&
|
||||
(Platform.isMacOS || Platform.isWindows || Platform.isLinux))
|
||||
ListTile(
|
||||
minTileHeight: 48,
|
||||
leading: const Icon(Symbols.file_upload),
|
||||
trailing: const Icon(Symbols.chevron_right),
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 24),
|
||||
title: Text('Load Miniapp from File'),
|
||||
onTap: () async {
|
||||
await MiniappLoader.loadMiniappFromSource(context, ref);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
minTileHeight: 48,
|
||||
leading: const Icon(Symbols.download),
|
||||
trailing: const Icon(Symbols.chevron_right),
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 24),
|
||||
title: Text('Load Miniapp from URL'),
|
||||
onTap: () async {
|
||||
await _showLoadFromUrlDialog(context, ref);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
minTileHeight: 48,
|
||||
leading: const Icon(Symbols.play_circle),
|
||||
trailing: const Icon(Symbols.chevron_right),
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 24),
|
||||
title: Text('Launch Miniapp'),
|
||||
onTap: () async {
|
||||
await _showMiniappSelector(context, ref);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _showLoadFromUrlDialog(
|
||||
BuildContext context,
|
||||
WidgetRef ref,
|
||||
) async {
|
||||
final TextEditingController controller = TextEditingController();
|
||||
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Load Miniapp from URL'),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Enter .evc file URL',
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(12)),
|
||||
),
|
||||
),
|
||||
autofocus: true,
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Load'),
|
||||
onPressed: () async {
|
||||
final url = controller.text.trim();
|
||||
if (url.isNotEmpty) {
|
||||
Navigator.of(context).pop();
|
||||
showLoadingModal(context);
|
||||
await MiniappLoader.loadMiniappFromUrl(context, ref, url);
|
||||
if (context.mounted) {
|
||||
hideLoadingModal(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _showMiniappSelector(BuildContext context, WidgetRef ref) async {
|
||||
final registry = ref.read(pluginRegistryProvider);
|
||||
final miniapps = registry.miniApps.values.toList();
|
||||
|
||||
if (miniapps.isEmpty) {
|
||||
showErrorAlert('No miniapps loaded');
|
||||
return;
|
||||
}
|
||||
|
||||
final selectedId = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Select Miniapp'),
|
||||
content: SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: miniapps.length,
|
||||
itemBuilder: (context, index) {
|
||||
final miniapp = miniapps[index];
|
||||
return ListTile(
|
||||
title: Text(miniapp.metadata.name),
|
||||
subtitle: Text(miniapp.metadata.description),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop(miniapp.metadata.id);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (selectedId != null && context.mounted) {
|
||||
await showMiniappModal(context, ref, selectedId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:island/modular/interface.dart';
|
||||
import 'package:island/pods/modular/plugin_registry.dart';
|
||||
|
||||
Future<void> showMiniappModal(
|
||||
BuildContext context,
|
||||
WidgetRef ref,
|
||||
String miniappId,
|
||||
) async {
|
||||
final registry = ref.read(pluginRegistryProvider);
|
||||
final miniapp = registry.getMiniApp(miniappId);
|
||||
|
||||
if (miniapp == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
await showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
builder: (context) {
|
||||
return MiniappDisplay(miniapp: miniapp);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
class MiniappDisplay extends StatelessWidget {
|
||||
final MiniApp miniapp;
|
||||
|
||||
const MiniappDisplay({super.key, required this.miniapp});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.of(context).size.height * 0.9,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: Theme.of(context).dividerColor,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Text('Miniapp', style: Theme.of(context).textTheme.titleMedium),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ProviderScope(
|
||||
child: Consumer(
|
||||
builder: (context, ref, child) {
|
||||
return miniapp.buildEntry();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user