index.dart 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import 'package:flutter/material.dart';
  2. import 'package:fun_selfie_app/widgets/home_button.dart';
  3. class PhotographyPage extends StatefulWidget {
  4. const PhotographyPage({Key? key}) : super(key: key);
  5. @override
  6. State<StatefulWidget> createState() => _PhotographyPageState();
  7. }
  8. class _PhotographyPageState extends State<PhotographyPage> {
  9. Widget renderImgBox(String imgSrc) {
  10. final screenSize = MediaQuery.of(context).size;
  11. return Container(
  12. padding: const EdgeInsets.only(left: 20),
  13. constraints: BoxConstraints(
  14. maxHeight: screenSize.height * 0.3, maxWidth: screenSize.width / 4),
  15. decoration: const BoxDecoration(
  16. boxShadow: [
  17. BoxShadow(
  18. color: Colors.black38,
  19. offset: Offset(0, 2),
  20. blurRadius: 5,
  21. spreadRadius: 3)
  22. ],
  23. ),
  24. child: Image(
  25. image: AssetImage(imgSrc),
  26. fit: BoxFit.fill,
  27. width: (screenSize.width - 100) / 4,
  28. ),
  29. );
  30. }
  31. @override
  32. Widget build(BuildContext context) {
  33. final screenSize = MediaQuery.of(context).size;
  34. return Scaffold(
  35. body: Container(
  36. width: screenSize.width,
  37. height: screenSize.height,
  38. decoration: const BoxDecoration(
  39. image: DecorationImage(
  40. fit: BoxFit.cover,
  41. image: AssetImage('static/images/photography_bg.png'))),
  42. child: Stack(children: <Widget>[
  43. Align(
  44. alignment: const Alignment(0, 0),
  45. child: SizedBox(
  46. width: 180,
  47. height: 60,
  48. child: ElevatedButton(
  49. child: const Text(
  50. '开始拍摄',
  51. style: TextStyle(fontSize: 20),
  52. ),
  53. onPressed: () {
  54. Navigator.pushNamed(context, "/takePhoto");
  55. },
  56. ))),
  57. const HomeButton(),
  58. Positioned(
  59. bottom: 0,
  60. left: 0,
  61. width: screenSize.width,
  62. // height: 200,
  63. child: Row(
  64. children: [
  65. renderImgBox('static/images/photo_img3.png'),
  66. renderImgBox('static/images/photo_img1.png'),
  67. renderImgBox('static/images/photo_img2.png'),
  68. renderImgBox('static/images/photo_img3.png'),
  69. ],
  70. ))
  71. ]),
  72. ));
  73. }
  74. }