Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added restaurant card implementation #1398

Merged
merged 5 commits into from
Jan 6, 2025
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
94 changes: 94 additions & 0 deletions packages/uni_ui/lib/cards/restaurant_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import 'package:flutter/material.dart';
import 'package:phosphor_flutter/phosphor_flutter.dart';
import 'package:uni_ui/cards/generic_card.dart';
import 'package:uni_ui/cards/widgets/restaurant_menu_item.dart';

class RestaurantCard extends StatelessWidget {
const RestaurantCard({
super.key,
required this.name,
required this.icon,
required this.menuItems,
required this.isFavorite,
required this.onFavoriteToggle,
});

final String name;
final Icon icon;
final List<RestaurantMenuItem> menuItems;
final bool isFavorite;
final VoidCallback onFavoriteToggle;

@override
Widget build(BuildContext context) {
return GenericCard(
key: key,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RestaurantCardHeader(
name: name,
icon: icon,
isFavorite: isFavorite,
onFavoriteToggle: onFavoriteToggle),
Column(
children: menuItems),
],
));
}
}

class RestaurantCardHeader extends StatelessWidget {
const RestaurantCardHeader({
super.key,
required this.name,
required this.icon,
required this.isFavorite,
required this.onFavoriteToggle,
});

final String name;
final Icon icon;
final bool isFavorite;
final VoidCallback onFavoriteToggle;

@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(bottom: 9),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Theme.of(context).dividerColor,
width: 1.0,
),
),
),
child: Row(
children: [
Expanded(
flex: 1,
child: icon),
Expanded(
flex: 4,
child: Text(
name,
style: Theme.of(context).textTheme.headlineSmall,
overflow: TextOverflow.ellipsis,
),
),
Expanded(
flex: 1,
child: IconButton(
onPressed: onFavoriteToggle,
icon: isFavorite
? Icon(PhosphorIconsFill.heart,
color: Theme.of(context).primaryColor)
: Icon(PhosphorIconsRegular.heart,
color: Theme.of(context).primaryColor)),
),
],
),
);
}
}
34 changes: 34 additions & 0 deletions packages/uni_ui/lib/cards/widgets/restaurant_menu_item.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'package:flutter/material.dart';

class RestaurantMenuItem extends StatelessWidget {
const RestaurantMenuItem({
super.key,
required this.name,
required this.icon});

final String name;
final Icon icon;

@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: icon),
Expanded(
flex: 5,
child: Text(
name,
style: Theme.of(context).textTheme.bodyLarge,
softWrap: true,
),
),
],
),
);
}
}
Loading