Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions lib/ui/components/cv_primary_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class CVPrimaryButton extends StatelessWidget {
this.isBodyText = false,
this.isPrimaryDark = false,
this.padding = const EdgeInsets.all(8),
this.textStyle,
super.key,
});

Expand All @@ -16,6 +17,26 @@ class CVPrimaryButton extends StatelessWidget {
final bool isBodyText;
final bool isPrimaryDark;
final EdgeInsetsGeometry padding;
final TextStyle? textStyle;

// Small button variant constructor
factory CVPrimaryButton.small({
required String title,
VoidCallback? onPressed,
bool isPrimaryDark = false,
}) {
return CVPrimaryButton(
title: title,
onPressed: onPressed,
isPrimaryDark: isPrimaryDark,
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 12),
textStyle: const TextStyle(
fontSize: 14,
color: Colors.white,
fontWeight: FontWeight.w500,
),
);
}

@override
Widget build(BuildContext context) {
Expand All @@ -29,13 +50,14 @@ class CVPrimaryButton extends StatelessWidget {
child: Text(
title,
style:
isBodyText
textStyle ??
(isBodyText
? Theme.of(
context,
).textTheme.bodyLarge?.copyWith(color: Colors.white)
: Theme.of(
context,
).textTheme.titleLarge?.copyWith(color: Colors.white),
).textTheme.titleLarge?.copyWith(color: Colors.white)),
),
);
}
Expand Down
69 changes: 51 additions & 18 deletions lib/ui/views/projects/components/featured_project_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class FeaturedProjectCard extends StatefulWidget {

class _FeaturedProjectCardState extends State<FeaturedProjectCard> {
Widget _buildPreview() {
final hasImage = widget.project.attributes.imagePreview.url.isNotEmpty;

return Container(
decoration: BoxDecoration(
border: Border.all(color: CVTheme.primaryColor),
Expand All @@ -36,24 +38,60 @@ class _FeaturedProjectCardState extends State<FeaturedProjectCard> {
),
child: AspectRatio(
aspectRatio: 1.6,
child: FadeInImage.memoryNetwork(
fit: BoxFit.cover,
placeholder: kTransparentImage,
image:
EnvironmentConfig.CV_API_BASE_URL.substring(
0,
EnvironmentConfig.CV_API_BASE_URL.length - 7,
) +
widget.project.attributes.imagePreview.url,
),
child:
hasImage
? FadeInImage.memoryNetwork(
fit: BoxFit.cover,
placeholder: kTransparentImage,
image: _getImageUrl(),
imageErrorBuilder:
(context, error, stackTrace) =>
_buildPlaceholderImage(),
)
: _buildPlaceholderImage(),
),
),
);
}

Widget _buildPlaceholderImage() {
return Container(
color: Color.lerp(CVTheme.primaryColorLight, Colors.white, 0.95),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.bolt,
size: 48,
color: Color.lerp(CVTheme.primaryColor, Colors.white, 0.7),
),
const SizedBox(height: 8),
Text(
'CircuitVerse Project',
style: TextStyle(
color: Color.lerp(CVTheme.primaryColor, Colors.white, 0.4),
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
],
),
),
);
}

String _getImageUrl() {
return EnvironmentConfig.CV_API_BASE_URL.substring(
0,
EnvironmentConfig.CV_API_BASE_URL.length - 7,
) +
widget.project.attributes.imagePreview.url;
}

Widget _buildFooter() {
return Container(
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 12),
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
decoration: const BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.only(
Expand All @@ -63,24 +101,19 @@ class _FeaturedProjectCardState extends State<FeaturedProjectCard> {
border: Border.fromBorderSide(BorderSide(color: CVTheme.primaryColor)),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
child: Text(
widget.project.attributes.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.start,
style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: CVTheme.textColor(context),
),
),
),
CVPrimaryButton(
title: 'View',
padding: const EdgeInsets.all(2),
onPressed: widget.onViewPressed,
),
const SizedBox(width: 10),
CVPrimaryButton.small(title: 'View', onPressed: widget.onViewPressed),
],
),
);
Expand Down
Loading