splash_content.dart
import 'package:flutter/material.dart';
import 'package:shop_app/constants.dart';
import 'package:shop_app/size_config.dart';
class SplashContent extends StatelessWidget {
const SplashContent({
Key key,
this.text,
this.image,
}) : super(key: key);
final String text, image;
@override
Widget build(BuildContext context) {
return Column(
children: [
Spacer(),
Text(
"UZ PLANET",
style: TextStyle(
fontSize: getProportionateScreenWidth(36),
color: kPrimaryColor,
fontWeight: FontWeight.bold),
),
Text(text,
textAlign: TextAlign.start,
),
Spacer(
flex: 2,
),
Image.asset(
image,
height: getProportionateScreenHeight(265),
width: getProportionateScreenWidth(235),
),
],
);
}
}
default_button.dart
import 'package:flutter/material.dart';
import '../constants.dart';
import '../size_config.dart';
class DefaultButton extends StatelessWidget {
const DefaultButton({
Key key, this.text, this.press
}) : super(key: key);
final String text;
final Function press;
@override
Widget build(BuildContext context) {
return SizedBox(
width: double.infinity,
height: getProportionateScreenHeight(56),
child: FlatButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
color: kPrimaryColor,
onPressed: press,
child: Text(
text,
style: TextStyle(
fontSize: getProportionateScreenWidth(18),
color: Colors.white),
)),
);
}
}
home_screen.dart
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:shop_app/example_screen.dart';
import 'package:shop_app/home/components/search_field.dart';
import 'package:shop_app/provider/country_provider.dart';
import '../constants.dart';
import '../size_config.dart';
import 'components/country_listtile_widget.dart';
class HomeScreen extends StatelessWidget {
static String routeName = "/home";
@override
Widget build(BuildContext context) {
final provider = Provider.of(context);
final allCountries = provider.countriesSorted;
SizeConfig().init(context);
return Provider(
create: (BuildContext context) =>provider,
child: Scaffold(
body: Column(
children: [
SizedBox(height: getProportionateScreenWidth(20)),
// SearchField(),
Padding(
padding: EdgeInsets.only(
top: getProportionateScreenWidth(10),
left: getProportionateScreenWidth(10),
right: getProportionateScreenWidth(10)),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: kSecondaryColor.withOpacity(0.1),
borderRadius: BorderRadius.circular(15)),
child: TextField(
onChanged: (value) {
provider.loadCountriesWithQuery(value);
},
decoration: InputDecoration(
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
hintText: "Qidiruv...",
prefixIcon: Icon(Icons.search),
contentPadding: EdgeInsets.symmetric(
horizontal: getProportionateScreenWidth(20),
vertical: getProportionateScreenWidth(11)),
),
),
),
),
Expanded(
child: ListView(
children: allCountries.map((country) {
return CountryListTileWidget(
country: country,
isSelected: false,
press: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ExampleScreen(
name: country.name.replaceAll(" ", "_").toLowerCase(),
),
),
),
);
}).toList(),
),
),
],
),
),
);
}
}
country_listtile_widget.dart
import 'package:flutter/material.dart';
import 'package:shop_app/models/country.dart';
import 'package:shop_app/size_config.dart';
import 'flag_widget.dart';
class CountryListTileWidget extends StatelessWidget {
final Country country;
final bool isSelected;
final GestureTapCallback press;
const CountryListTileWidget({
Key key,
@required this.country,
// @required this.isNative,
@required this.isSelected,
@required this.press,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final selectedColor = Theme
.of(context)
.primaryColor;
final style = isSelected
? TextStyle(
fontSize: 18,
color: selectedColor,
fontWeight: FontWeight.bold,
)
: TextStyle(fontSize: 18);
return GestureDetector(
onTap: press,
child: Padding(
padding: EdgeInsets.only(left:getProportionateScreenWidth(8),right: getProportionateScreenWidth(8)),
child: Card(
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
child: Column(
children: [
Row(
children: [
Column(
children: [
Padding(
padding: EdgeInsets.all(10),
child: FlagWidget(code: country.code),
),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
country.name,
textAlign: TextAlign.start,
style: TextStyle(
fontSize: 17, fontWeight: FontWeight.bold),
),
Text(
country.capital,
style: TextStyle(fontStyle: FontStyle.italic),
),
],
)
],
),
],
),
),
),
);
}
}
Do'stlaringiz bilan baham: |