Skip to content

Commit bae23b3

Browse files
Marketing goldens, some theming, API refactor (#55)
1 parent c7e91b8 commit bae23b3

File tree

103 files changed

+3648
-1115
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+3648
-1115
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import 'dart:async';
2+
import 'dart:io';
3+
4+
import 'package:flutter_test_goldens/flutter_test_goldens.dart';
5+
import 'package:super_text_layout/super_text_layout.dart';
6+
7+
Future<void> testExecutable(FutureOr<void> Function() testMain) async {
8+
// Adjust the theme that's applied to all golden tests in this suite.
9+
GoldenSceneTheme.push(GoldenSceneTheme.standard.copyWith(
10+
directory: Directory("."),
11+
));
12+
13+
// Disable animations in Super Editor.
14+
BlinkController.indeterminateAnimationsEnabled = false;
15+
16+
return testMain();
17+
}
49.5 KB
Loading
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
import 'package:flutter_test_goldens/flutter_test_goldens.dart';
4+
import 'package:shadcn_ui/shadcn_ui.dart';
5+
6+
import '../shadcn_test_tools.dart';
7+
8+
void main() {
9+
group("Marketing >", () {
10+
testGoldenScene("gallery", (tester) async {
11+
FtgLog.initAllLogs();
12+
13+
// The following code is broken up so it can spread across multiple slides.
14+
final gallery = Gallery(
15+
"Gallery",
16+
fileName: "gallery",
17+
itemScaffold: shadcnItemScaffold,
18+
layout: ShadcnGalleryLayout(
19+
shadcnWordmarkProvider: shadcnWordmarkProvider,
20+
),
21+
);
22+
23+
gallery
24+
.itemFromWidget(
25+
id: "1",
26+
description: "Primary",
27+
widget: ShadButton(
28+
child: const Text('Primary'),
29+
onPressed: () {},
30+
),
31+
)
32+
.itemFromWidget(
33+
id: "2",
34+
description: "Secondary",
35+
widget: ShadButton.secondary(
36+
child: const Text('Secondary'),
37+
onPressed: () {},
38+
),
39+
)
40+
.itemFromWidget(
41+
id: "3",
42+
description: "Destructive",
43+
widget: ShadButton.destructive(
44+
child: const Text('Destructive'),
45+
onPressed: () {},
46+
),
47+
)
48+
.itemFromWidget(
49+
id: "4",
50+
description: "Ghost",
51+
widget: ShadButton.ghost(
52+
child: const Text('Ghost'),
53+
onPressed: () {},
54+
),
55+
)
56+
.itemFromWidget(
57+
id: "5",
58+
description: "Link",
59+
widget: ShadButton.ghost(
60+
child: const Text('Link'),
61+
onPressed: () {},
62+
),
63+
)
64+
.itemFromWidget(
65+
id: "6",
66+
description: "Icon + Label",
67+
widget: ShadButton(
68+
onPressed: () {},
69+
leading: const Icon(LucideIcons.mail),
70+
child: const Text('Login with Email'),
71+
),
72+
)
73+
.itemFromBuilder(
74+
id: "7",
75+
description: "Loading",
76+
builder: (context) {
77+
return ShadButton(
78+
onPressed: () {},
79+
leading: SizedBox.square(
80+
dimension: 16,
81+
child: CircularProgressIndicator(
82+
strokeWidth: 2,
83+
color: ShadTheme.of(context).colorScheme.primaryForeground,
84+
),
85+
),
86+
child: const Text('Please wait'),
87+
);
88+
},
89+
)
90+
.itemFromWidget(
91+
id: "8",
92+
description: "Gradient + Shadow",
93+
widget: ShadButton(
94+
onPressed: () {},
95+
gradient: const LinearGradient(colors: [
96+
Colors.cyan,
97+
Colors.indigo,
98+
]),
99+
shadows: [
100+
BoxShadow(
101+
color: Colors.blue.withOpacity(.4),
102+
spreadRadius: 4,
103+
blurRadius: 10,
104+
offset: const Offset(0, 2),
105+
),
106+
],
107+
child: const Text('Gradient with Shadow'),
108+
),
109+
);
110+
111+
await gallery.run(tester);
112+
});
113+
});
114+
}
508 KB
Loading
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import 'dart:math';
2+
3+
import 'package:flutter/material.dart';
4+
5+
class AngledLinePainter extends CustomPainter {
6+
AngledLinePainter({
7+
required this.angleDegrees,
8+
required this.gap,
9+
required this.thickness,
10+
required this.lineColor,
11+
this.backgroundColor = Colors.transparent,
12+
});
13+
14+
final double angleDegrees;
15+
final double gap;
16+
final double thickness;
17+
final Color lineColor;
18+
final Color backgroundColor;
19+
20+
@override
21+
void paint(Canvas canvas, Size size) {
22+
final rect = Offset.zero & size;
23+
canvas
24+
..save()
25+
..clipRect(rect);
26+
27+
// Fill background.
28+
canvas.drawRect(rect, Paint()..color = backgroundColor);
29+
30+
// Draw lines.
31+
final paint = Paint()
32+
..color = lineColor
33+
..strokeWidth = thickness;
34+
35+
final angleRadians = angleDegrees * pi / 180;
36+
37+
// Calculate line direction
38+
final dx = cos(angleRadians);
39+
final dy = sin(angleRadians);
40+
final direction = Offset(dx, dy);
41+
final perpendicular = Offset(-dy, dx); // unit perpendicular vector
42+
43+
// Calculate diagonal length to cover the canvas
44+
final diagonal = sqrt(size.width * size.width + size.height * size.height);
45+
46+
// Center of canvas
47+
final center = Offset(size.width / 2, size.height / 2);
48+
49+
// Number of lines needed to cover the canvas
50+
final numLines = (diagonal / gap).ceil();
51+
52+
for (int i = -numLines; i <= numLines; i++) {
53+
final offset = perpendicular * (i * gap);
54+
final start = center + offset - direction * diagonal;
55+
final end = center + offset + direction * diagonal;
56+
57+
canvas.drawLine(start, end, paint);
58+
}
59+
60+
canvas.restore();
61+
}
62+
63+
@override
64+
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
65+
}
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)