pos changes
This commit is contained in:
66
lib/core/widgets/brand_mark.dart
Normal file
66
lib/core/widgets/brand_mark.dart
Normal file
@@ -0,0 +1,66 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../constants/asset_paths.dart';
|
||||
import '../theme/app_colors.dart';
|
||||
|
||||
/// The Nearle mark on its tile.
|
||||
///
|
||||
/// Every surface that shows the brand — login, sidebar, cashier header —
|
||||
/// renders this, so the mark cannot drift between them. It replaces the
|
||||
/// hand-drawn letter "N" in a gradient box that each of those screens used to
|
||||
/// build for itself.
|
||||
class BrandMark extends StatelessWidget {
|
||||
const BrandMark({
|
||||
super.key,
|
||||
this.size = 36,
|
||||
this.radius,
|
||||
this.onDark = false,
|
||||
});
|
||||
|
||||
final double size;
|
||||
final double? radius;
|
||||
|
||||
/// Set on a coloured background, where the tile needs no border to separate
|
||||
/// it from what is behind.
|
||||
final bool onDark;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final corner = BorderRadius.circular(radius ?? size * 0.28);
|
||||
|
||||
return Container(
|
||||
width: size,
|
||||
height: size,
|
||||
// Clipped, not padded: the mark fills the tile edge to edge and the
|
||||
// rounded corner does the trimming, so nothing can spill past the box
|
||||
// whatever aspect ratio the file happens to have.
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: corner,
|
||||
border: onDark ? null : Border.all(color: AppColors.border),
|
||||
),
|
||||
child: Image.asset(
|
||||
AssetPaths.logo,
|
||||
fit: BoxFit.fill,
|
||||
width: size,
|
||||
height: size,
|
||||
filterQuality: FilterQuality.medium,
|
||||
// A missing or undeclared asset would otherwise blank the brand out
|
||||
// of the sidebar entirely; the letterform is a poor substitute but a
|
||||
// better failure than nothing.
|
||||
errorBuilder: (context, _, __) => FittedBox(
|
||||
fit: BoxFit.contain,
|
||||
child: Text(
|
||||
'N',
|
||||
style: TextStyle(
|
||||
color: AppColors.primary,
|
||||
fontWeight: FontWeight.w800,
|
||||
fontSize: size,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user