Skip to content

Instantly share code, notes, and snippets.

@Slozzyondul
Last active January 22, 2025 20:16
Show Gist options
  • Save Slozzyondul/ce9156f0e42e11908d834d2c739970e5 to your computer and use it in GitHub Desktop.
Save Slozzyondul/ce9156f0e42e11908d834d2c739970e5 to your computer and use it in GitHub Desktop.
Check if my homepage is ok for a simple webapp
import 'package:dog_food/methods/build_drop_down.dart';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
late double device_width, device_height;
@override
Widget build(BuildContext context) {
device_width = MediaQuery.of(context).size.width;
device_height = MediaQuery.of(context).size.height;
return SafeArea(
child: Scaffold(
appBar: AppBar(
leading: Builder(
builder: (BuildContext context) {
return GestureDetector(
onTap: () {},
child: Image.asset(
"/assets/images/logo.png",
height: device_height * 0.3,
),
);
},
),
// backgroundColor: Color.fromRGBO(248, 249, 250, 1),
backgroundColor: const Color.fromRGBO(179, 128, 86, 1),
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Spacer(),
buildDropdownTab(
context,
"Dog Food",
[
const PopupMenuItem(
value: "dry",
child: Text(
"Dry Food",
style: TextStyle(color: Color.fromRGBO(139, 94, 60, 1)),
),
),
const PopupMenuItem(
value: "wet",
child: Text(
"Wet Food",
style: TextStyle(color: Color.fromRGBO(139, 94, 60, 1)),
),
),
const PopupMenuItem(
value: "snacks",
child: Text(
"Snacks",
style: TextStyle(color: Color.fromRGBO(139, 94, 60, 1)),
),
),
],
),
buildDropdownTab(
context,
"Our Story",
[
const PopupMenuItem(
value: "about",
child: Text(
"About Us",
style: TextStyle(color: Color.fromRGBO(139, 94, 60, 1)),
),
),
const PopupMenuItem(
value: "values",
child: Text(
"Our Values",
style: TextStyle(color: Color.fromRGBO(139, 94, 60, 1)),
),
),
const PopupMenuItem(
value: "team",
child: Text(
"Team",
style: TextStyle(color: Color.fromRGBO(139, 94, 60, 1)),
),
),
],
),
buildDropdownTab(
context,
"Contact Us",
[
const PopupMenuItem(
value: "email",
child: Text(
"Email",
style: TextStyle(color: Color.fromRGBO(139, 94, 60, 1)),
),
),
const PopupMenuItem(
value: "phone",
child: Text(
"Phone",
style: TextStyle(color: Color.fromRGBO(139, 94, 60, 1)),
),
),
const PopupMenuItem(
value: "location",
child: Text(
"Location",
style: TextStyle(color: Color.fromRGBO(139, 94, 60, 1)),
),
),
],
),
],
),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
homeBannerWidget(context),
sellingPointWidget(),
bestSellerWidget(),
],
),
),
);
}
Widget homeBannerWidget(BuildContext context) {
return Container(
width: double.infinity,
height: device_height * 0.35,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/assets/images/banner5.png'),
fit: BoxFit.cover,
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Text
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16.0), // Add horizontal padding
child: AutoSizeText.rich(
TextSpan(
text: 'HEALTHY, HAPPY PETS\n',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: const Color.fromRGBO(179, 128, 86, 1),
shadows: [
Shadow(
offset: const Offset(0, 1),
blurRadius: 3,
color: Colors.black.withOpacity(0.5),
),
],
),
children: const [
TextSpan(
text: 'STARTS HERE!\n\n',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w600,
),
),
TextSpan(
text: 'High-protein kibble\n',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w500,
color: Color.fromRGBO(179, 128, 86, 1),
),
),
TextSpan(
text: 'Delivered fresh to your door\n',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w500,
color: Color.fromRGBO(179, 128, 86, 1),
),
),
],
),
textAlign: TextAlign.center,
maxLines: 5, // Adjust to fit within space
minFontSize: 12, // Minimum font size for responsiveness
),
),
SizedBox(
height:
device_height * 0.1), // Add spacing between text and button
// Sign Up Button
ElevatedButton(
onPressed: () async {
const url = 'https://wa.me/message/UTDJXATS2FQXM1';
if (await canLaunch(url)) {
await launch(url);
} else {
// Handle error if the URL cannot be launched
print('Could not launch $url');
}
},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(horizontal: 40, vertical: 15),
backgroundColor: Colors.white70,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
child: const Text(
'Shop Now',
style: TextStyle(
fontSize: 18,
color: Color.fromRGBO(0, 77, 64, 1),
fontWeight: FontWeight.bold),
),
),
],
),
);
}
Widget sellingPoint({required IconData icon, required String text}) {
return Row(
mainAxisSize: MainAxisSize.min, // Minimize horizontal space usage
children: [
Container(
color: Colors.white,
child: Icon(
icon,
color: Colors.white,
size: 20, // Adjust icon size if needed
),
),
const SizedBox(width: 4), // Spacing between icon and text
Text(
text,
style: const TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.bold,
),
),
],
);
}
Widget sellingPointWidget() {
return Container(
padding: const EdgeInsets.symmetric(vertical: 16.0),
//color: const Color.fromRGBO(0, 77, 64, 1),
color: Color.fromRGBO(179, 128, 86, 1),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
sellingPoint(
icon: Icons.verified,
text: "Satisfaction guaranteed",
),
sellingPoint(
icon: Icons.grain,
text: "Grain free",
),
sellingPoint(
icon: Icons.local_shipping,
text: "Free delivery",
),
],
),
);
}
Widget bestSellerWidget() {
return Container();
}
}
import 'package:flutter/material.dart';
Widget buildDropdownTab(BuildContext context, String title, List<PopupMenuEntry> items) {
return PopupMenuButton(
onSelected: (value) {
// Handle navigation or actions here
print("Selected: $value");
},
itemBuilder: (BuildContext context) => items,
child: Row(
children: [
Text(
title,
style: const TextStyle(color: Colors.white, fontSize: 18),
),
const Icon(Icons.arrow_drop_down, color: Colors.white),
],
),
);
}
@Slozzyondul
Copy link
Author

what do you think of my homepage, building a web site first might transition to app later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment