import 'package:flutter/material.dart';

import '../common/assets.dart';
import '../common/button.dart';
import '../pages/login.dart';

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

  //按钮组
  Widget _bulidBtns(BuildContext context) {
    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按钮
          ButtonWidget(
            text: "Get Started",
            width: 139,
            height: 42,
            radius: 32,
            onPressed: () => Navigator.push(context,
                MaterialPageRoute(builder: ((context) => const LoginPage()))),
          ),
        ],
      ),
    );
  }

  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(BuildContext context) {
    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(context),

        //end
      ],
    );
  }

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