This repository has been archived on 2026-10-23. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
halkyon_shared/packages/halkyon_ui/example/lib/main.dart

75 lines
2.4 KiB
Dart
Raw Normal View History

import 'package:halkyon_ui/halkyon_ui.dart';
import 'package:material_ui/material_ui.dart';
void main() {
registerFontLicenses();
runApp(const ExampleApp());
}
/// An app set up as Halkyon's are: the shared theme in both brightnesses,
/// the package's texts beside Material's (from material_ui, whose own
/// delegates serve its widgets), and snack bars fitted to the window.
class const ExampleApp({
/// The language, the device's when null.
final Locale? locale,
super.key,
}) extends StatelessWidget {
@override
Widget build(BuildContext context) => MaterialApp(
title: 'Halkyon Example',
theme: appTheme(Brightness.light),
darkTheme: appTheme(Brightness.dark),
locale: locale,
localizationsDelegates: const [
HalkyonUiLocalizations.delegate,
...GlobalMaterialLocalizations.delegates,
],
supportedLocales: HalkyonUiLocalizations.supportedLocales,
builder: (context, child) => FittedSnackBars(child: child!),
home: const _Home(),
);
}
class const _Home() extends StatelessWidget {
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
return TopGradient(
background: scheme.surface,
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(backgroundColor: Colors.transparent),
body: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: readableContentMaxWidth,
),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const BrandWordmark(product: 'Example'),
const SizedBox(height: 24),
SectionCard(
child: Builder(
builder: (context) => FilledButton.tonal(
onPressed: () => confirmDestructiveAction(
context,
title: 'Delete everything?',
message: 'It can’t be undone.',
confirmLabel: 'Delete',
),
child: const Text('Delete'),
),
),
),
],
),
),
),
),
),
);
}
}