commit
6bd3c17cdf
@ -0,0 +1,38 @@
|
||||
name: Deploy to Cloudflare Workers
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'stable'
|
||||
# Match local development version which provides Dart 3.11.0
|
||||
flutter-version: '3.41.2'
|
||||
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: latest
|
||||
|
||||
- name: Get dependencies
|
||||
run: flutter pub get
|
||||
|
||||
- name: Build Web
|
||||
run: bun run build
|
||||
|
||||
- name: Deploy to Cloudflare
|
||||
uses: cloudflare/wrangler-action@v3
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
command: deploy
|
||||
@ -0,0 +1,89 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
|
||||
class ChromeRequiredScreen extends StatelessWidget {
|
||||
const ChromeRequiredScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final theme = Theme.of(context);
|
||||
final isDark = theme.brightness == Brightness.dark;
|
||||
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: isDark
|
||||
? [const Color(0xFF1A1A1A), const Color(0xFF0D0D0D)]
|
||||
: [const Color(0xFFF5F7FA), const Color(0xFFE4E7EB)],
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.orange.withValues(alpha: 0.1),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.browser_not_supported_rounded,
|
||||
size: 80,
|
||||
color: Colors.orange,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
Text(
|
||||
l10n.scanner_chromeRequired,
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.headlineMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: isDark ? Colors.white : Colors.black87,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
l10n.scanner_chromeRequiredMessage,
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.bodyLarge?.copyWith(
|
||||
color: isDark ? Colors.white70 : Colors.black54,
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 48),
|
||||
// We can't really "fix" it for them other than telling them to use Chrome
|
||||
// but we can provide a nice visual.
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
border: Border.all(color: Colors.blue.withValues(alpha: 0.3)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.info_outline, size: 20, color: Colors.blue),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
"Web Bluetooth requires a Chromium browser",
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: Colors.blue,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
export 'browser_detection_stub.dart'
|
||||
if (dart.library.js_interop) 'browser_detection_web.dart';
|
||||
@ -0,0 +1,3 @@
|
||||
class BrowserDetection {
|
||||
static bool get isChrome => false;
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
import 'package:web/web.dart' as web;
|
||||
|
||||
class BrowserDetection {
|
||||
static bool get isChrome {
|
||||
final userAgent = web.window.navigator.userAgent.toLowerCase();
|
||||
final isChrome = userAgent.contains('chrome');
|
||||
return isChrome;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'dart:io' show Platform;
|
||||
import 'browser_detection.dart';
|
||||
|
||||
/// Utility class to safely check the current platform across web and native.
|
||||
///
|
||||
/// Using `Platform` from `dart:io` directly on Web causes a crash.
|
||||
/// This class handles the `kIsWeb` check first to avoid those crashes.
|
||||
class PlatformInfo {
|
||||
/// Whether the app is running in a web browser.
|
||||
static bool get isWeb => kIsWeb;
|
||||
|
||||
/// Whether the app is running in the Chrome browser (only relevant if [isWeb] is true).
|
||||
static bool get isChrome => isWeb && BrowserDetection.isChrome;
|
||||
|
||||
/// Whether the app is running on Android.
|
||||
static bool get isAndroid => !kIsWeb && Platform.isAndroid;
|
||||
|
||||
/// Whether the app is running on iOS.
|
||||
static bool get isIOS => !kIsWeb && Platform.isIOS;
|
||||
|
||||
/// Whether the app is running on macOS.
|
||||
static bool get isMacOS => !kIsWeb && Platform.isMacOS;
|
||||
|
||||
/// Whether the app is running on Windows.
|
||||
static bool get isWindows => !kIsWeb && Platform.isWindows;
|
||||
|
||||
/// Whether the app is running on Linux.
|
||||
static bool get isLinux => !kIsWeb && Platform.isLinux;
|
||||
|
||||
/// Whether the app is running on a mobile platform (Android or iOS).
|
||||
static bool get isMobile => isAndroid || isIOS;
|
||||
|
||||
/// Whether the app is running on a desktop platform (macOS, Windows, or Linux).
|
||||
static bool get isDesktop => isMacOS || isWindows || isLinux;
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "meshcore-open",
|
||||
"scripts": {
|
||||
"build": "dart run build_pipe:build",
|
||||
"deploy": "bun x wrangler deploy"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
#:schema node_modules/wrangler/config-schema.json
|
||||
name = "meshcore"
|
||||
compatibility_date = "2025-10-08"
|
||||
|
||||
[assets]
|
||||
directory = "build/web"
|
||||
|
||||
Loading…
Reference in new issue