import 'package:flutter/material.dart';

import '../common/assets.dart';

class WelcomePage extends StatelessWidget {
  const WelcomePage({Key? key}) : super(key: key);

  //按钮组
  Widget _bulidBtns() {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 20),
      child: Row(
        children: [
          //skip按钮
          TextButton(
            onPressed: () {},
            child: const Text('Skip',
                style: TextStyle(
                  fontSize: 15,
                  color: Color(0xff2B2A2A),
                  fontWeight: FontWeight.w300,
                )),
          ),

          //弹开
          const Spacer(),

          //getstarted按钮
          //套一层Container，可以做很多事，比如设置尺寸
          Container(
            height: 42,
            width: 139,
            //需要裁切，不然没有圆角
            clipBehavior: Clip.antiAlias,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(32),
            ),
            child: ElevatedButton(
              onPressed: (() {}),
              style: ButtonStyle(
                  elevation: MaterialStateProperty.all(0),
                  //设置最小值为0，是的尺寸为children尺寸
                  minimumSize: MaterialStateProperty.all(Size.zero)),
              child: const Text('Get Started',
                  style: TextStyle(
                    fontSize: 16,
                    color: Colors.white,
                    fontWeight: FontWeight.w300,
                  )),
            ),
          ),
        ],
      ),
    );
  }

  Padding _bulidText() {
    return const Padding(
      padding: EdgeInsets.symmetric(horizontal: 38),
      child: Text(
        'Browse & Oder All Products at Any Time',
        style: TextStyle(
          fontSize: 20,
          fontWeight: FontWeight.bold,
          color: Color(0xff2B2A2A),
          height: 23 / 20,
        ),
      ),
    );
  }

  Widget _buildView() {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        //标题
        _bulidText(),

        const SizedBox(
          height: 70,
        ),

        //图片
        Image.asset(AssetsImages.welcomePng,
            height: 300,
            //宽撑满
            width: double.infinity,
            fit: BoxFit.fitWidth),

        const SizedBox(
          height: 70,
        ),
        //按钮组
        _bulidBtns(),

        //end
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(child: _buildView()),
    );
  }
}
