class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: PreferredSize(
preferredSize: const Size.fromHeight(0.0),
child: AppBar(
centerTitle: true,
title: const Text(" ",
textDirection: TextDirection.ltr,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black,
fontFamily: 'Comic Sans MS',
fontSize: 0.0,
fontWeight: FontWeight.w800,
)),
backgroundColor: Colors.transparent,
elevation: 0),
),
body: LayoutBuilder(builder: (context, constraints) {
final mediaQuery = MediaQuery.of(context);
final screenHeight = mediaQuery.size.height;
final statusBarHeight = mediaQuery.padding.top;
double containerHeight = screenHeight - statusBarHeight; // 高度的0.333
double containerWidth = containerHeight * 0.490; // 宽度的1.342倍
double containerhappyHeight = containerHeight * 0.086;
double containersizeHeight = containerHeight * 0.023;
double containerhumanpictureHeight = containerHeight * 0.5 -
containerhappyHeight -
containersizeHeight;
return Container(
width: containerWidth,
height: containerHeight,
alignment: Alignment.center,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/background.jpg"),
fit: BoxFit.fill)),
child: Column(children: [
Container(
constraints: BoxConstraints(
maxWidth: containerWidth, // 最大宽度
maxHeight: containerHeight * 0.5, // 最大高度
),
alignment: Alignment.topCenter,
color: Colors.transparent,
child: Column(children: [
Container(
width: containerWidth,
height: containerhappyHeight,
alignment: Alignment.bottomCenter,
color: Colors.red,
child: const Text("Healthy and Happy",
textDirection: TextDirection.ltr,
style: TextStyle(
color: Colors.black,
fontFamily: 'Comic Sans MS',
fontSize: 39.0,
fontWeight: FontWeight.w800)),
),
Container(
alignment: Alignment.bottomCenter,
color: Colors.transparent,
child: Column(children: [
Container(
width: containerWidth,
height: containersizeHeight,
color: Colors.black,
),
Container(
width: containerWidth,
height: containerhumanpictureHeight,
color: Colors.transparent,
child: ImageButtonhuman()),
])),
])),
Container(
width: containerWidth,
height: containerHeight * 0.5,
alignment: Alignment.topCenter,
color: Colors.blue,
child: Column(children: [
Container(
width: containerWidth,
height: 385,
alignment: Alignment.topCenter,
color: Colors.transparent,
child: Row(children: [
Container(
child: Column(children: [
SizedBox(
width: 200,
height: 30,
),
Container(
child: Row(
children: [
SizedBox(
width: 15,
height: 350,
),
Container(
width: 185,
height: 350,
color: Colors.red,
child: ImageButtoncbt())
],
))
])),
Container(
width: 225,
height: 400,
alignment: Alignment.center,
color: Colors.transparent,
child: Column(children: [
SizedBox(
width: 225,
height: 36,
),
Container(
width: 225,
height: 150,
alignment: Alignment.center,
color: Colors.transparent,
child: Row(
children: [
Container(
width: 112,
height: 150,
alignment: Alignment.center,
color: Colors.transparent,
child: Row(
children: [
SizedBox(
width: 15,
height: 150,
),
Container(
width: 97,
height: 150,
color: Colors.red,
child: ImageButtonsos()),
],
)),
Container(
width: 112,
height: 150,
alignment: Alignment.center,
color: Colors.red,
child: ImageButtonaction())
],
)),
Container(
width: 112,
height: 5,
color: Colors.transparent,
),
Container(
width: 225,
height: 140,
alignment: Alignment.center,
color: Colors.transparent,
child: Row(
children: [
SizedBox(
width: 15,
height: 140,
),
Container(
width: 210,
height: 140,
alignment: Alignment.center,
color: Colors.red,
child: ImageButtonsofa(),
)
],
)),
]),
),
])),
Container(
width: 430,
height: 53,
alignment: Alignment.bottomCenter,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
"assets/images/darkbackgound.jpg"),
fit: BoxFit.fill)),
child: Row(
children: [
Container(
width: 107,
height: 52,
alignment: Alignment.center,
color: Colors.transparent,
child: ImageButtoncommunity(),
),
Container(
width: 106,
height: 52,
alignment: Alignment.center,
color: Colors.transparent,
child: ImageButtonknowledge(),
),
Container(
width: 106,
height: 52,
alignment: Alignment.center,
color: Colors.transparent,
child: ImageButtonpsychology(),
),
Container(
width: 107,
height: 52,
alignment: Alignment.center,
color: Colors.transparent,
child: ImageButtonme(),
),
],
))
]),
)
]));
}));
}
}
class ImageButtonhuman extends StatelessWidget {
const ImageButtonhuman({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: GestureDetector(
onTap: () {
// 按钮点击逻辑,如导航或显示对话框
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const SecondPage()), // 目标页面
);
},
child: LayoutBuilder(builder: (context, constraints) {
final mediaQuery = MediaQuery.of(context);
final screenHeight = mediaQuery.size.height;
final statusBarHeight = mediaQuery.padding.top;
double containerHeight = screenHeight - statusBarHeight;
double containerWidth = containerHeight * 0.490;
double humanpictureWidth = containerWidth * 0.790;
double humanpictureHeight = containerHeight * 0.365;
return Container(
width: humanpictureWidth,
height: humanpictureHeight,
alignment: Alignment.center,
child: Container(
width: humanpictureWidth,
height: humanpictureHeight,
alignment: Alignment.center,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/human.jpg"),
fit: BoxFit.fill)),
));
}),
/*Image.asset(
'assets/images/human.jpg', // 替换为您的图片路径
width: humanpictureWidth,
height: 320,
fit: BoxFit.cover,
),*/
),
),
backgroundColor: Colors.transparent,
);
}
}
class ImageButtoncbt extends StatelessWidget {
const ImageButtoncbt({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: GestureDetector(
onTap: () {
// 按钮点击逻辑,如导航或显示对话框
/* ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('按钮被点击!')),
);*/
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const ThirdPage()), // 目标页面
);
},
child: Image.asset(
'assets/images/cbt.jpg', // 替换为您的图片路径
width: 1850,
height: 350,
alignment: Alignment.topCenter,
),
),
backgroundColor: Colors.transparent,
);
}
}
class ImageButtonsos extends StatelessWidget {
const ImageButtonsos({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const SosPage()), // 目标页面
);
},
child: Column(
children: [
Image.asset(
'assets/images/sos.jpg', // 替换为您的图片路径
width: 80,
height: 133,
alignment: Alignment.center,
),
const Text('情绪急救按钮',
textDirection: TextDirection.ltr,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black,
fontFamily: 'Comic Sans MS',
fontSize: 11.0,
fontWeight: FontWeight.w200))
],
)),
backgroundColor: Colors.transparent,
);
}
}
class ImageButtonaction extends StatelessWidget {
const ImageButtonaction({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const ActionPage()), // 目标页面
);
},
child: Column(
children: [
Image.asset(
'assets/images/action.jpg', // 替换为您的图片路径
width: 90,
height: 133,
alignment: Alignment.center,
),
const Text('立刻行动',
textDirection: TextDirection.ltr,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black,
fontFamily: 'Comic Sans MS',
fontSize: 11.0,
fontWeight: FontWeight.w200))
],
)),
backgroundColor: Colors.transparent,
);
}
}
class ImageButtonsofa extends StatelessWidget {
const ImageButtonsofa({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const MeditationPage()), // 目标页面
);
},
child: Column(
children: [
Image.asset(
'assets/images/sofa.jpg', // 替换为您的图片路径
width: 190,
height: 107,
alignment: Alignment.center,
),
const Text('冥想',
textDirection: TextDirection.ltr,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black,
fontFamily: 'Comic Sans MS',
fontSize: 11.0,
fontWeight: FontWeight.w200))
],
)),
backgroundColor: Colors.transparent,
);
}
}
class ImageButtoncommunity extends StatelessWidget {
const ImageButtoncommunity({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: GestureDetector(
onTap: () {
// 按钮点击逻辑,如导航或显示对话框
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('按钮被点击!')),
);
},
child: Column(
children: [
Image.asset(
'assets/images/community.jpg', // 替换为您的图片路径
width: 106,
height: 40,
alignment: Alignment.center,
),
const Text('AI咨询',
textDirection: TextDirection.ltr,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black,
fontFamily: 'Comic Sans MS',
fontSize: 8.0,
fontWeight: FontWeight.w200))
],
)),
backgroundColor: Colors.transparent,
);
}
}
class ImageButtonknowledge extends StatelessWidget {
const ImageButtonknowledge({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: GestureDetector(
onTap: () {
// 按钮点击逻辑,如导航或显示对话框
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('按钮被点击!')),
);
},
child: Column(
children: [
Image.asset(
'assets/images/knowledge.jpg', // 替换为您的图片路径
width: 106,
height: 40,
alignment: Alignment.center,
),
const Text('知识',
textDirection: TextDirection.ltr,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black,
fontFamily: 'Comic Sans MS',
fontSize: 8.0,
fontWeight: FontWeight.w200))
],
)),
backgroundColor: Colors.transparent,
);
}
}
class ImageButtonpsychology extends StatelessWidget {
const ImageButtonpsychology({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: GestureDetector(
onTap: () {
// 按钮点击逻辑,如导航或显示对话框
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('按钮被点击!')),
);
},
child: Column(
children: [
Image.asset(
'assets/images/psychology.jpg', // 替换为您的图片路径
width: 106,
height: 40,
alignment: Alignment.center,
),
const Text('心理',
textDirection: TextDirection.ltr,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black,
fontFamily: 'Comic Sans MS',
fontSize: 8.0,
fontWeight: FontWeight.w200))
],
)),
backgroundColor: Colors.transparent,
);
}
}
class ImageButtonme extends StatelessWidget {
const ImageButtonme({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: GestureDetector(
onTap: () {
// 按钮点击逻辑,如导航或显示对话框
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('按钮被点击!')),
);
},
child: Column(
children: [
Image.asset(
'assets/images/me.jpg', // 替换为您的图片路径
width: 107,
height: 40,
alignment: Alignment.center,
),
const Text('个人',
textDirection: TextDirection.ltr,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black,
fontFamily: 'Comic Sans MS',
fontSize: 8.0,
fontWeight: FontWeight.w200))
],
)),
backgroundColor: Colors.transparent,
);
}
}
这个代码为什么会超出屏幕
最新发布