
Replaces hardcoded colors and standard Theme.of(context) accesses with a custom AppTheme. Introduces distinct light and dark themes and persists the selected theme mode using shared_preferences. Integrates the theme into the main app structure and applies it to various components and pages. Adds google_fonts dependency for theme typography.
45 lines
1.3 KiB
Dart
45 lines
1.3 KiB
Dart
import 'package:barcode_scanner/components/loading_progress_component.dart';
|
|
import 'package:barcode_scanner/themes/app_theme.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class PrimaryButtonComponent extends StatelessWidget {
|
|
const PrimaryButtonComponent({
|
|
super.key,
|
|
required this.text,
|
|
required this.onPressed,
|
|
this.loading = false,
|
|
});
|
|
final void Function()? onPressed;
|
|
final String text;
|
|
final bool loading;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: AppTheme.of(context).primary,
|
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
|
),
|
|
onPressed: loading ? null : onPressed,
|
|
child: loading
|
|
? SizedBox(
|
|
height: 20,
|
|
width: 20,
|
|
child: Center(
|
|
child: LoadingProgressComponent(
|
|
color: AppTheme.of(context).primary,
|
|
),
|
|
),
|
|
)
|
|
: Text(
|
|
text,
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
color: AppTheme.of(context).primaryText,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|