Skip to content

Commit

Permalink
✨ (flutter-web-deploy.yml): downgrade Flutter version to 3.24.5 for c…
Browse files Browse the repository at this point in the history
…ompatibility

🔧 (supabase_config.dart): switch from dotenv to environment variables for Supabase configuration
📝 (environment_config.dart): remove dotenv loading and use environment variables for configuration
🌐 (index.html): add language attribute and improve meta tags for better SEO
📝 (index.html): update title and description for clarity and branding
💡 (index.html): add loading message and error handling for better user experience
📝 (manifest.json): update app name and description for consistency and branding
  • Loading branch information
mariepop13 committed Jan 3, 2025
1 parent d51d47c commit df617e4
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 55 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/flutter-web-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.27.1'
flutter-version: '3.24.5'
channel: 'stable'

- name: Verify Flutter and Dart versions
Expand Down Expand Up @@ -55,6 +55,12 @@ jobs:
run: flutter build web --base-href="/chromaniac/"
env:
FLUTTER_WEB_CANVASKIT_URL: https://unpkg.com/[email protected]/bin/
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
OCO_EMOJI: 'true'
OCO_MODEL: 'gpt-4o-mini'
OCO_LANGUAGE: 'en'

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
Expand Down
28 changes: 14 additions & 14 deletions lib/utils/config/environment_config.dart
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter/foundation.dart';
import 'package:chromaniac/utils/logger/app_logger.dart';

class EnvironmentConfig {
static Future<void> initialize() async {
try {
AppLogger.d('Attempting to load .env file...');
const envFile = ".env";
await dotenv.load(fileName: envFile);
AppLogger.i('Successfully loaded .env file');
AppLogger.d('Initializing environment configuration');
// No need to load .env file
AppLogger.i('Environment configuration initialized');
} catch (e) {
AppLogger.e('Critical error loading .env file: $e');
// Optionally, you can rethrow the error to prevent app startup
// rethrow;
AppLogger.e('Error during environment configuration: $e');
}
}

static String get openRouterApiKey {
final key = dotenv.env['OPENROUTER_API_KEY'];
if (key == null || key.isEmpty) {
AppLogger.w('OPENROUTER_API_KEY not found in environment variables');
// Use environment variable for web, fallback for other platforms
const key = String.fromEnvironment('OPENROUTER_API_KEY',
defaultValue: 'default_key_if_not_set');

if (key.isEmpty) {
AppLogger.w('OPENROUTER_API_KEY not found');
return '';
}
return key;
}

static String get emojiSetting {
return dotenv.env['OCO_EMOJI'] ?? 'true';
return const String.fromEnvironment('OCO_EMOJI', defaultValue: 'true');
}

static String get languageSetting {
return dotenv.env['OCO_LANGUAGE'] ?? 'en';
return const String.fromEnvironment('OCO_LANGUAGE', defaultValue: 'en');
}

static String get modelSetting {
return dotenv.env['OCO_MODEL'] ?? 'gpt-4o-mini';
return const String.fromEnvironment('OCO_MODEL', defaultValue: 'gpt-4o-mini');
}
}
54 changes: 27 additions & 27 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ packages:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: "16e298750b6d0af7ce8a3ba7c18c69c3785d11b15ec83f6dcd0ad2a0009b3cab"
sha256: f256b0c0ba6c7577c15e2e4e114755640a875e885099367bf6e012b19314c834
url: "https://pub.dev"
source: hosted
version: "76.0.0"
version: "72.0.0"
_macros:
dependency: transitive
description: dart
source: sdk
version: "0.3.3"
version: "0.3.2"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: "1f14db053a8c23e260789e9b0980fa27f2680dd640932cae5e1137cce0e46e1e"
sha256: b652861553cd3990d8ed361f7979dc6d7053a9ac8843fa73820ab68ce5410139
url: "https://pub.dev"
source: hosted
version: "6.11.0"
version: "6.7.0"
app_links:
dependency: "direct main"
description:
Expand Down Expand Up @@ -194,10 +194,10 @@ packages:
dependency: "direct main"
description:
name: collection
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.19.0"
version: "1.18.0"
convert:
dependency: transitive
description:
Expand Down Expand Up @@ -585,18 +585,18 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.dev"
source: hosted
version: "10.0.7"
version: "10.0.5"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.dev"
source: hosted
version: "3.0.8"
version: "3.0.5"
leak_tracker_testing:
dependency: transitive
description:
Expand Down Expand Up @@ -633,10 +633,10 @@ packages:
dependency: transitive
description:
name: macros
sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656"
sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536"
url: "https://pub.dev"
source: hosted
version: "0.1.3-main.0"
version: "0.1.2-main.4"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -1001,7 +1001,7 @@ packages:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
version: "0.0.99"
source_gen:
dependency: transitive
description:
Expand Down Expand Up @@ -1102,10 +1102,10 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.12.0"
version: "1.11.1"
storage_client:
dependency: transitive
description:
Expand Down Expand Up @@ -1134,10 +1134,10 @@ packages:
dependency: transitive
description:
name: string_scanner
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.3.0"
version: "1.2.0"
supabase:
dependency: transitive
description:
Expand Down Expand Up @@ -1174,26 +1174,26 @@ packages:
dependency: "direct main"
description:
name: test
sha256: "713a8789d62f3233c46b4a90b174737b2c04cb6ae4500f2aa8b1be8f03f5e67f"
sha256: "7ee44229615f8f642b68120165ae4c2a75fe77ae2065b1e55ae4711f6cf0899e"
url: "https://pub.dev"
source: hosted
version: "1.25.8"
version: "1.25.7"
test_api:
dependency: transitive
description:
name: test_api
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.dev"
source: hosted
version: "0.7.3"
version: "0.7.2"
test_core:
dependency: transitive
description:
name: test_core
sha256: "12391302411737c176b0b5d6491f466b0dd56d4763e347b6714efbaa74d7953d"
sha256: "55ea5a652e38a1dfb32943a7973f3681a60f872f8c3a05a14664ad54ef9c6696"
url: "https://pub.dev"
source: hosted
version: "0.6.5"
version: "0.6.4"
timing:
dependency: transitive
description:
Expand Down Expand Up @@ -1294,10 +1294,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "14.3.0"
version: "14.2.5"
watcher:
dependency: transitive
description:
Expand Down Expand Up @@ -1379,5 +1379,5 @@ packages:
source: hosted
version: "2.0.3"
sdks:
dart: ">=3.6.0 <4.0.0"
dart: ">=3.5.4 <4.0.0"
flutter: ">=3.24.0"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: '>=3.6.0 <4.0.0'
sdk: '>=3.5.4 <4.0.0'

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
Expand Down
51 changes: 44 additions & 7 deletions web/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<!--
If you are serving your web app in a path other than the root, change the
Expand All @@ -17,22 +17,59 @@
<base href="$FLUTTER_BASE_HREF">

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="A new Flutter project.">
<meta name="description" content="Chromaniac - Color Palette Generator">

<!-- iOS meta tags & icons -->
<!-- iOS and Mobile Web App Meta Tags -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="chromaniac">
<link rel="apple-touch-icon" href="icons/Icon-192.png">
<meta name="apple-mobile-web-app-title" content="Chromaniac">

<!-- Favicon -->
<!-- Favicon and Touch Icons -->
<link rel="icon" type="image/png" href="favicon.png"/>
<link rel="apple-touch-icon" href="icons/Icon-192.png">

<!-- Performance Optimization -->
<link rel="preload" href="flutter_bootstrap.js" as="script">
<link rel="preconnect" href="https://unpkg.com" crossorigin>

<title>chromaniac</title>
<title>Chromaniac - Color Palette Generator</title>
<link rel="manifest" href="manifest.json">

<style>
body {
margin: 0;
padding: 0;
background-color: #ffffff;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}
#loading {
text-align: center;
color: #333;
font-size: 18px;
}
</style>
</head>
<body>
<div id="loading">
<p>Loading Chromaniac...</p>
<small>Initializing color magic ✨</small>
</div>

<script>
window.addEventListener('error', function(event) {
console.error('Unhandled error:', event.error);
document.getElementById('loading').innerHTML =
'<p style="color:red">Oops! Something went wrong while loading the app.</p>';
});
</script>

<script src="flutter_bootstrap.js" async></script>
</body>
</html>
10 changes: 5 additions & 5 deletions web/manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "chromaniac",
"short_name": "chromaniac",
"name": "Chromaniac",
"short_name": "Chromaniac",
"start_url": ".",
"display": "standalone",
"background_color": "#hexcode",
"theme_color": "#hexcode",
"description": "A new Flutter project.",
"background_color": "#ffffff",
"theme_color": "#000000",
"description": "A color palette generator app",
"orientation": "portrait-primary",
"prefer_related_applications": false,
"icons": [
Expand Down

0 comments on commit df617e4

Please sign in to comment.