Remove noise
This commit is contained in:
@@ -1,90 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:ente_strings/ente_strings.dart';
|
||||
|
||||
/// Example widget demonstrating how to use the ente_strings package
|
||||
class ExampleStringUsage extends StatelessWidget {
|
||||
const ExampleStringUsage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Ente Strings Example'),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Network Error Message:',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// Example 1: Using the extension method
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red[50],
|
||||
border: Border.all(color: Colors.red[200]!),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
context.strings.networkHostLookUpErr,
|
||||
style: const TextStyle(color: Colors.red),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'Alternative usage:',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// Example 2: Using the traditional approach
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.orange[50],
|
||||
border: Border.all(color: Colors.orange[200]!),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
StringsLocalizations.of(context).networkHostLookUpErr,
|
||||
style: const TextStyle(color: Colors.orange),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Example main app demonstrating setup
|
||||
class ExampleApp extends StatelessWidget {
|
||||
const ExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Ente Strings Example',
|
||||
// Configure localization delegates
|
||||
localizationsDelegates: [
|
||||
...StringsLocalizations.localizationsDelegates,
|
||||
// Add your other app-specific delegates here
|
||||
],
|
||||
supportedLocales: StringsLocalizations.supportedLocales,
|
||||
home: const ExampleStringUsage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
runApp(const ExampleApp());
|
||||
}
|
||||
@@ -1,225 +0,0 @@
|
||||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: async
|
||||
sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.13.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: boolean_selector
|
||||
sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: characters
|
||||
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.4.0"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: clock
|
||||
sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.2"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.19.1"
|
||||
ente_strings:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "1.0.0"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fake_async
|
||||
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.3"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: flutter_lints
|
||||
sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.0.0"
|
||||
flutter_localizations:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
intl:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: intl
|
||||
sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.20.2"
|
||||
leak_tracker:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker
|
||||
sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "10.0.9"
|
||||
leak_tracker_flutter_testing:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker_flutter_testing
|
||||
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.9"
|
||||
leak_tracker_testing:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker_testing
|
||||
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: lints
|
||||
sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.1.1"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.12.17"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.11.1"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.16.0"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.9.1"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_span
|
||||
sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.10.1"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stack_trace
|
||||
sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.12.1"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_channel
|
||||
sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: string_scanner
|
||||
sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.4.1"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.2"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.4"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_math
|
||||
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
vm_service:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vm_service
|
||||
sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "15.0.0"
|
||||
sdks:
|
||||
dart: ">=3.7.0-0 <4.0.0"
|
||||
flutter: ">=3.18.0-18.0.pre.54"
|
||||
@@ -1,22 +0,0 @@
|
||||
name: ente_strings_example
|
||||
description: Example app demonstrating the ente_strings package
|
||||
version: 1.0.0
|
||||
publish_to: none
|
||||
|
||||
environment:
|
||||
sdk: ">=3.0.0 <4.0.0"
|
||||
flutter: ">=1.17.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
ente_strings:
|
||||
path: ../
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_lints: ^5.0.0
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
@@ -1,206 +0,0 @@
|
||||
// Demo showing the color system migration is complete
|
||||
// This file demonstrates that the new color system works correctly
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import '../theme/colors.dart';
|
||||
import '../theme/ente_theme.dart';
|
||||
import '../theme/ente_theme_data.dart';
|
||||
|
||||
/// Demo widget showing the new color system in action
|
||||
class ColorMigrationDemo extends StatelessWidget {
|
||||
const ColorMigrationDemo({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// NEW: Preferred way to access colors
|
||||
final colorScheme = Theme.of(context).extension<EnteColorScheme>() ??
|
||||
getEnteColorScheme(context);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: colorScheme.backgroundBase,
|
||||
appBar: AppBar(
|
||||
backgroundColor: colorScheme.backgroundElevated,
|
||||
title: Text(
|
||||
'Color Migration Demo',
|
||||
style: TextStyle(color: colorScheme.textBase),
|
||||
),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildSection(
|
||||
colorScheme,
|
||||
'Background Colors',
|
||||
color: colorScheme.backgroundElevated,
|
||||
border: colorScheme.strokeFaint,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildSection(
|
||||
colorScheme,
|
||||
'Primary Colors',
|
||||
color: colorScheme.primary500,
|
||||
textColor: colorScheme.backgroundBase,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildGradientSection(colorScheme),
|
||||
const SizedBox(height: 16),
|
||||
_buildSection(
|
||||
colorScheme,
|
||||
'Warning Colors',
|
||||
color: colorScheme.warning500.withOpacity(0.1),
|
||||
border: colorScheme.warning500,
|
||||
textColor: colorScheme.warning700,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildSection(
|
||||
colorScheme,
|
||||
'Fill Colors',
|
||||
color: colorScheme.fillFaint,
|
||||
textColor: colorScheme.textMuted,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildMigrationInfo(colorScheme),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSection(
|
||||
EnteColorScheme colorScheme,
|
||||
String title, {
|
||||
required Color color,
|
||||
Color? border,
|
||||
Color? textColor,
|
||||
}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
border: border != null ? Border.all(color: border) : null,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
'$title ✅',
|
||||
style: TextStyle(
|
||||
color: textColor ?? colorScheme.textBase,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildGradientSection(EnteColorScheme colorScheme) {
|
||||
return Container(
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: colorScheme.gradientButtonBgColors,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Gradient Colors ✅',
|
||||
style: TextStyle(
|
||||
color: colorScheme.backgroundBase,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMigrationInfo(EnteColorScheme colorScheme) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.primary500.withOpacity(0.1),
|
||||
border: Border.all(color: colorScheme.primary500),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Migration Complete! 🎉',
|
||||
style: TextStyle(
|
||||
color: colorScheme.primary700,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'• All components migrated to new color system\n'
|
||||
'• Theme-aware colors with fallback support\n'
|
||||
'• Custom branding support ready\n'
|
||||
'• Performance optimized with const colors\n'
|
||||
'• Type-safe with compile-time validation',
|
||||
style: TextStyle(
|
||||
color: colorScheme.textBase,
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Example of creating custom app themes
|
||||
class CustomAppThemeExample {
|
||||
// Purple brand theme
|
||||
static final purpleScheme = ColorSchemeBuilder.fromPrimaryColor(
|
||||
const Color(0xFF6C5CE7),
|
||||
);
|
||||
|
||||
// Blue brand theme
|
||||
static final blueScheme = ColorSchemeBuilder.fromPrimaryColor(
|
||||
const Color(0xFF2196F3),
|
||||
);
|
||||
|
||||
// Green brand theme
|
||||
static final greenScheme = ColorSchemeBuilder.fromPrimaryColor(
|
||||
const Color(0xFF4CAF50),
|
||||
);
|
||||
|
||||
// Create theme data for each brand
|
||||
static ThemeData purpleLightTheme = createAppThemeData(
|
||||
brightness: Brightness.light,
|
||||
colorScheme: purpleScheme.light,
|
||||
);
|
||||
|
||||
static ThemeData purpleDarkTheme = createAppThemeData(
|
||||
brightness: Brightness.dark,
|
||||
colorScheme: purpleScheme.dark,
|
||||
);
|
||||
|
||||
static ThemeData blueLightTheme = createAppThemeData(
|
||||
brightness: Brightness.light,
|
||||
colorScheme: blueScheme.light,
|
||||
);
|
||||
|
||||
static ThemeData blueDarkTheme = createAppThemeData(
|
||||
brightness: Brightness.dark,
|
||||
colorScheme: blueScheme.dark,
|
||||
);
|
||||
}
|
||||
|
||||
/// Example app showing how to use the new color system
|
||||
class ColorSystemExampleApp extends StatelessWidget {
|
||||
const ColorSystemExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Color System Demo',
|
||||
theme: CustomAppThemeExample.blueLightTheme,
|
||||
darkTheme: CustomAppThemeExample.blueDarkTheme,
|
||||
home: const ColorMigrationDemo(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
// Test to validate the color system migration
|
||||
// This file is for verification purposes only
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import '../theme/colors.dart';
|
||||
import '../theme/ente_theme.dart';
|
||||
import '../theme/ente_theme_data.dart';
|
||||
|
||||
/// Test widget to verify the new color system works correctly
|
||||
class ColorSystemTestWidget extends StatelessWidget {
|
||||
const ColorSystemTestWidget({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Test that we can access the color scheme from theme
|
||||
final colorScheme = Theme.of(context).extension<EnteColorScheme>();
|
||||
|
||||
// Test that fallback to old system works
|
||||
final fallbackColorScheme = colorScheme ?? getEnteColorScheme(context);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: fallbackColorScheme.backgroundBase,
|
||||
appBar: AppBar(
|
||||
backgroundColor: fallbackColorScheme.backgroundElevated,
|
||||
title: Text(
|
||||
'Color System Test',
|
||||
style: TextStyle(color: fallbackColorScheme.textBase),
|
||||
),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Test basic colors
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: fallbackColorScheme.backgroundElevated,
|
||||
border: Border.all(color: fallbackColorScheme.strokeFaint),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
'Background Colors Working',
|
||||
style: TextStyle(color: fallbackColorScheme.textBase),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Test primary colors
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: fallbackColorScheme.primary500,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
'Primary Colors Working',
|
||||
style: TextStyle(color: fallbackColorScheme.backgroundBase),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Test gradient colors
|
||||
Container(
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: fallbackColorScheme.gradientButtonBgColors,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Gradient Colors Working',
|
||||
style: TextStyle(
|
||||
color: fallbackColorScheme.backgroundBase,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Test warning colors
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: fallbackColorScheme.warning500.withOpacity(0.1),
|
||||
border: Border.all(color: fallbackColorScheme.warning500),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
'Warning Colors Working',
|
||||
style: TextStyle(color: fallbackColorScheme.warning700),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Test fill colors
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: fallbackColorScheme.fillFaint,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
'Fill Colors Working',
|
||||
style: TextStyle(color: fallbackColorScheme.textMuted),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Example showing how apps can create custom themes
|
||||
class CustomThemeExample {
|
||||
// Create a custom purple theme
|
||||
static final purpleSchemes = ColorSchemeBuilder.fromPrimaryColor(
|
||||
const Color(0xFF6C5CE7), // Purple brand color
|
||||
);
|
||||
|
||||
static final lightTheme = createAppThemeData(
|
||||
brightness: Brightness.light,
|
||||
colorScheme: purpleSchemes.light,
|
||||
);
|
||||
|
||||
static final darkTheme = createAppThemeData(
|
||||
brightness: Brightness.dark,
|
||||
colorScheme: purpleSchemes.dark,
|
||||
);
|
||||
}
|
||||
|
||||
/// Example showing migration from old to new system
|
||||
class MigrationExample extends StatelessWidget {
|
||||
const MigrationExample({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// OLD WAY (still works for backward compatibility)
|
||||
// final colorScheme = getEnteColorScheme(context);
|
||||
|
||||
// NEW WAY (preferred)
|
||||
// final colorScheme = Theme.of(context).extension<EnteColorScheme>()!;
|
||||
|
||||
// SAFE WAY (with fallback)
|
||||
final safeColorScheme = Theme.of(context).extension<EnteColorScheme>() ??
|
||||
getEnteColorScheme(context);
|
||||
|
||||
return Container(
|
||||
color: safeColorScheme.backgroundBase,
|
||||
child: Text(
|
||||
'Migration Example',
|
||||
style: TextStyle(color: safeColorScheme.textBase),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// A comprehensive color scheme for consistent theming across apps.
|
||||
///
|
||||
/// This color scheme provides all the colors needed for a modern Flutter app,
|
||||
/// including background, text, fill, stroke, and accent colors for both light
|
||||
/// and dark themes.
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
// Example: How to use the reusable EnteColorScheme in your app
|
||||
// filepath: example_app_colors.dart
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'colors.dart'; // Import the reusable color scheme
|
||||
import 'ente_theme_data.dart'; // Import the theme data helper
|
||||
import 'ente_theme.dart'; // Import for getEnteColorScheme
|
||||
|
||||
/// Example 1: Using the default color scheme
|
||||
class DefaultThemeExample {
|
||||
static final lightTheme = createAppThemeData(
|
||||
brightness: Brightness.light,
|
||||
colorScheme: lightScheme,
|
||||
);
|
||||
|
||||
static final darkTheme = createAppThemeData(
|
||||
brightness: Brightness.dark,
|
||||
colorScheme: darkScheme,
|
||||
);
|
||||
}
|
||||
|
||||
/// Example 2: Creating a custom theme with brand colors
|
||||
class CustomBrandThemeExample {
|
||||
// Define your app's brand colors
|
||||
static const Color brandPrimaryColor = Color(0xFF6C5CE7); // Purple
|
||||
|
||||
static final schemes = ColorSchemeBuilder.fromPrimaryColor(brandPrimaryColor);
|
||||
|
||||
static final lightTheme = createAppThemeData(
|
||||
brightness: Brightness.light,
|
||||
colorScheme: schemes.light,
|
||||
);
|
||||
|
||||
static final darkTheme = createAppThemeData(
|
||||
brightness: Brightness.dark,
|
||||
colorScheme: schemes.dark,
|
||||
);
|
||||
}
|
||||
|
||||
/// Example 3: Creating a theme with fully custom primary colors
|
||||
class FullyCustomThemeExample {
|
||||
static final schemes = ColorSchemeBuilder.fromCustomColors(
|
||||
primary700: const Color(0xFF1565C0), // Dark blue
|
||||
primary500: const Color(0xFF2196F3), // Material blue
|
||||
primary400: const Color(0xFF42A5F5), // Light blue
|
||||
primary300: const Color(0xFF90CAF9), // Very light blue
|
||||
iconButtonColor: const Color(0xFF1976D2), // Custom icon color
|
||||
gradientButtonBgColors: const [
|
||||
Color(0xFF1565C0),
|
||||
Color(0xFF2196F3),
|
||||
Color(0xFF42A5F5),
|
||||
],
|
||||
);
|
||||
|
||||
static final lightTheme = createAppThemeData(
|
||||
brightness: Brightness.light,
|
||||
colorScheme: schemes.light,
|
||||
);
|
||||
|
||||
static final darkTheme = createAppThemeData(
|
||||
brightness: Brightness.dark,
|
||||
colorScheme: schemes.dark,
|
||||
);
|
||||
}
|
||||
|
||||
/// Example 4: Using factory constructors for fine-grained control
|
||||
class FactoryConstructorExample {
|
||||
static final lightScheme = EnteColorScheme.light(
|
||||
primary700: const Color(0xFFE91E63), // Pink 700
|
||||
primary500: const Color(0xFFF06292), // Pink 300
|
||||
primary400: const Color(0xFFF8BBD9), // Pink 200
|
||||
primary300: const Color(0xFFFCE4EC), // Pink 50
|
||||
warning500: const Color(0xFFFF5722), // Custom warning color
|
||||
);
|
||||
|
||||
static final darkScheme = EnteColorScheme.dark(
|
||||
primary700: const Color(0xFFE91E63),
|
||||
primary500: const Color(0xFFF06292),
|
||||
primary400: const Color(0xFFF8BBD9),
|
||||
primary300: const Color(0xFFFCE4EC),
|
||||
warning500: const Color(0xFFFF5722),
|
||||
);
|
||||
|
||||
static final lightTheme = createAppThemeData(
|
||||
brightness: Brightness.light,
|
||||
colorScheme: lightScheme,
|
||||
);
|
||||
|
||||
static final darkTheme = createAppThemeData(
|
||||
brightness: Brightness.dark,
|
||||
colorScheme: darkScheme,
|
||||
);
|
||||
}
|
||||
|
||||
/// Helper function to get the current color scheme from context
|
||||
EnteColorScheme getColorScheme(BuildContext context) {
|
||||
return getEnteColorScheme(context);
|
||||
}
|
||||
|
||||
/// Example widget showing how to use the color scheme in your UI
|
||||
class ExampleWidget extends StatelessWidget {
|
||||
const ExampleWidget({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = getColorScheme(context);
|
||||
|
||||
return Container(
|
||||
color: colorScheme.backgroundBase,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.backgroundElevated,
|
||||
border: Border.all(color: colorScheme.strokeFaint),
|
||||
),
|
||||
child: Text(
|
||||
'Example Text',
|
||||
style: TextStyle(color: colorScheme.textBase),
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: colorScheme.primary500,
|
||||
foregroundColor: colorScheme.backgroundBase,
|
||||
),
|
||||
onPressed: () {},
|
||||
child: const Text('Primary Button'),
|
||||
),
|
||||
Container(
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: colorScheme.gradientButtonBgColors,
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Gradient Button',
|
||||
style: TextStyle(
|
||||
color: colorScheme.backgroundBase,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user