135 lines
3.8 KiB
Dart
135 lines
3.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:plant_app/constants.dart';
|
|
import 'package:plant_app/screens/details/detail_screen.dart';
|
|
|
|
class RecommendsPlants extends StatelessWidget {
|
|
const RecommendsPlants({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SingleChildScrollView(
|
|
scrollDirection: Axis.horizontal,
|
|
child: Row(
|
|
children: [
|
|
RecommendPlantCard(
|
|
image: "assets/images/image_1.png",
|
|
title: "Samantha",
|
|
country: "Russia",
|
|
price: 440,
|
|
press: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => DetailsScreen(),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
RecommendPlantCard(
|
|
image: "assets/images/image_2.png",
|
|
title: "Angelica",
|
|
country: "Russia",
|
|
price: 440,
|
|
press: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => DetailsScreen(),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
RecommendPlantCard(
|
|
image: "assets/images/image_3.png",
|
|
title: "Samantha",
|
|
country: "Russia",
|
|
price: 440,
|
|
press: () {},
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class RecommendPlantCard extends StatelessWidget {
|
|
const RecommendPlantCard({
|
|
super.key,
|
|
required this.image,
|
|
required this.title,
|
|
required this.country,
|
|
required this.price,
|
|
required this.press,
|
|
});
|
|
|
|
final String image, title, country;
|
|
final int price;
|
|
final VoidCallback press;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Size size = MediaQuery.of(context).size;
|
|
return Container(
|
|
margin: const EdgeInsets.only(
|
|
left: kDefaultPadding,
|
|
top: kDefaultPadding / 2,
|
|
bottom: kDefaultPadding * 2.5,
|
|
),
|
|
width: size.width * 0.4,
|
|
child: Column(
|
|
children: [
|
|
Image.asset(image),
|
|
GestureDetector(
|
|
onTap: press,
|
|
child: Container(
|
|
padding: const EdgeInsets.all(kDefaultPadding / 2),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
// 此处仅仅调整下部圆角 上部圆角依靠的是图片自身的圆角
|
|
borderRadius: const BorderRadius.only(
|
|
bottomLeft: Radius.circular(10),
|
|
bottomRight: Radius.circular(10),
|
|
),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
offset: const Offset(0, 10),
|
|
blurRadius: 50,
|
|
color: kPrimaryColor.withOpacity(0.23),
|
|
),
|
|
],
|
|
),
|
|
child: Row(
|
|
children: [
|
|
RichText(
|
|
text: TextSpan(
|
|
children: [
|
|
TextSpan(
|
|
text: "$title\n".toUpperCase(),
|
|
style: Theme.of(context).textTheme.labelLarge,
|
|
),
|
|
TextSpan(
|
|
text: country.toUpperCase(),
|
|
style: TextStyle(
|
|
color: kPrimaryColor.withOpacity(0.5),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const Spacer(),
|
|
Text(
|
|
'\$$price',
|
|
style: Theme.of(context).textTheme.labelLarge?.copyWith(
|
|
color: kPrimaryColor,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|