import 'package:flutter/material.dart';
import 'ask_question.dart';

class CommunityHomePage extends StatefulWidget {
  const CommunityHomePage({super.key});

  @override
  State<CommunityHomePage> createState() => _CommunityHomePageState();
}

class _CommunityHomePageState extends State<CommunityHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: SingleChildScrollView(
            child: Column(
      children: [
        const Divider(height: 10),
        _cardBox(context, 'Ask Question', 'images/ask_question.jpg',
            onPressed: () {
          Navigator.push(
            context,
            MaterialPageRoute(builder: (context) => const AskQuestionPage()),
          );
        }),
        const Divider(height: 10),
        _cardBox(
          context,
          'Browse Community',
          'images/browse_community.jpg',
          onPressed: () {},
        ),
        //const Divider(height: 10),
      ],
    )));
  }
}

Widget _cardBox(BuildContext context, String text, String image,
    {required void Function() onPressed}) {
  return Container(
    width: double.infinity,
    height: 200,
    decoration: BoxDecoration(
      color: Colors.white,
      borderRadius: BorderRadius.circular(10),
      border: Border.all(color: Colors.black, width: 2),
    ),
    child: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Text(
          text,
          style: const TextStyle(fontSize: 20, color: Colors.black),
        ),
        Image.asset(
          image,
          fit: BoxFit.cover,
          height: 150,
        ),
        GestureDetector(
          onTap: onPressed,
          child: Container(),
        ),
      ],
    ),
  );
}
