Better form and remove squares
All checks were successful
ci/woodpecker/push/build Pipeline was successful

Signed-off-by: Nikolai Rodionov <allanger@posteo.de>
This commit is contained in:
Nikolai Rodionov
2026-05-28 23:58:08 +02:00
parent aeb5269fc5
commit 84d65786bf
9 changed files with 215 additions and 122 deletions

View File

@@ -1,89 +1,91 @@
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:softplayer_web/shared/ui/colors/light_mode.dart';
class AuthDecoration extends StatelessWidget {
final double spacing;
final Color color;
const AuthDecoration({
super.key,
this.spacing = 24,
this.color = Colors.blue,
});
const AuthDecoration({super.key});
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
return Container(
color: LightModeColors.backgroundElevated,
child: FractionallySizedBox(
widthFactor: 0.3,
alignment: Alignment.centerLeft,
child: CustomPaint(
painter: _GridPainter(spacing: spacing, color: color),
child: const SizedBox.expand(),
),
),
);
},
return Container(
color: LightModeColors.backgroundElevated,
child: FractionallySizedBox(
alignment: Alignment.centerLeft,
child: const CustomPaint(
painter: _GradientPainter(),
child: SizedBox.expand(),
),
),
);
}
}
// todo: Some AI generated shite, that doesn't work
class _GridPainter extends CustomPainter {
final double spacing;
final Color color;
_GridPainter({required this.spacing, required this.color});
static const double maxSquare = 85;
static const double minSquare = 48; // 2x gap
class _GradientPainter extends CustomPainter {
const _GradientPainter();
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()..color = color;
// 🎨 Main smooth background gradient
final rect = Offset.zero & size;
// ✅ outer padding included in layout math
final innerWidth = size.width - spacing * 2;
final innerHeight = size.height - spacing * 2;
final backgroundGradient = const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFF0F172A), // deep navy
Color(0xFF111827), // dark slate
],
);
int columns = 10;
final paint = Paint()..shader = backgroundGradient.createShader(rect);
double calcSize(int cols) {
return (innerWidth - (cols - 1) * spacing) / cols;
}
canvas.drawRect(rect, paint);
// choose columns safely
while (columns > 1 && calcSize(columns) < minSquare) {
columns--;
}
// 🌈 soft glowing blobs (adds "cool gradient feel")
_drawGlow(
canvas,
size,
offset: const Offset(0.2, 0.3),
radius: size.width * 0.8,
colors: [Colors.cyan.withOpacity(0.25), Colors.transparent],
);
double square = calcSize(columns);
square = math.min(square, maxSquare);
_drawGlow(
canvas,
size,
offset: const Offset(0.8, 0.6),
radius: size.width * 0.9,
colors: [Colors.purple.withOpacity(0.20), Colors.transparent],
);
final rows = (innerHeight / (square + spacing)).ceil();
_drawGlow(
canvas,
size,
offset: const Offset(0.5, 0.9),
radius: size.width * 0.7,
colors: [Colors.blue.withOpacity(0.20), Colors.transparent],
);
}
for (int row = 0; row < rows; row++) {
final y = spacing + row * (square + spacing);
void _drawGlow(
Canvas canvas,
Size size, {
required Offset offset,
required double radius,
required List<Color> colors,
}) {
final center = Offset(size.width * offset.dx, size.height * offset.dy);
for (int col = 0; col < columns; col++) {
final x = spacing + col * (square + spacing);
final gradient = RadialGradient(colors: colors, radius: 1.0);
final rect = Rect.fromLTWH(x, y, square, square);
final paint = Paint()
..shader = gradient.createShader(
Rect.fromCircle(center: center, radius: radius),
)
..maskFilter = const MaskFilter.blur(BlurStyle.normal, 60);
canvas.drawRRect(
RRect.fromRectAndRadius(rect, const Radius.circular(6)),
paint,
);
}
}
canvas.drawCircle(center, radius, paint);
}
@override
bool shouldRepaint(covariant _GridPainter oldDelegate) {
return oldDelegate.spacing != spacing || oldDelegate.color != color;
}
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}