AppBar and Header components

This commit is contained in:
2024-05-02 15:04:05 +03:00
parent 0a491ca34b
commit 727c04d368
6 changed files with 155 additions and 106 deletions

View File

@@ -0,0 +1,36 @@
import 'package:flutter/material.dart';
class GymLinkAppBar extends StatelessWidget implements PreferredSizeWidget {
const GymLinkAppBar({super.key});
@override
Widget build(BuildContext context) {
return AppBar(
backgroundColor: Colors.white,
shadowColor: null,
automaticallyImplyLeading: false,
elevation: 0,
scrolledUnderElevation: 4,
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(right: 8),
child: Image.asset('logo.png', width: 24, height: 24),
),
Align(
alignment: Alignment.centerRight,
child: Text(
'Powered by GymLink',
style: Theme.of(context).textTheme.titleSmall,
),
),
],
),
toolbarHeight: 30,
);
}
@override
Size get preferredSize => const Size.fromHeight(30);
}

View File

@@ -0,0 +1,26 @@
import 'package:flutter/material.dart';
class GymLinkHeader extends StatelessWidget {
final String title;
const GymLinkHeader({super.key, required this.title});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
children: [
Row(
children: [
IconButton(
onPressed: () => Navigator.pop(context),
icon: const Icon(Icons.arrow_back)),
Text(title, style: Theme.of(context).textTheme.titleLarge),
],
),
const Divider(thickness: 1, height: 0),
],
),
);
}
}

View File

@@ -3,6 +3,7 @@ import 'dart:js_interop' as js;
import 'dart:js_interop_unsafe' as js_util; import 'dart:js_interop_unsafe' as js_util;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gymlink_module_web/components/app_bar.dart';
import 'package:gymlink_module_web/components/card.dart'; import 'package:gymlink_module_web/components/card.dart';
import 'package:gymlink_module_web/pages/basket.dart'; import 'package:gymlink_module_web/pages/basket.dart';
import 'package:gymlink_module_web/pages/detail.dart'; import 'package:gymlink_module_web/pages/detail.dart';
@@ -122,29 +123,7 @@ class _MainPageState extends State<MainPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: widget.isLoading appBar: widget.isLoading ? null : const GymLinkAppBar(),
? null
: AppBar(
backgroundColor: Colors.white,
elevation: 0,
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(right: 8),
child: Image.asset('logo.png', width: 24, height: 24),
),
Align(
alignment: Alignment.centerRight,
child: Text(
'Powered by GymLink',
style: Theme.of(context).textTheme.titleSmall,
),
),
],
),
toolbarHeight: 30,
),
body: widget.isLoading body: widget.isLoading
? const Center(child: CircularProgressIndicator()) ? const Center(child: CircularProgressIndicator())
: Column( : Column(

View File

@@ -1,4 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gymlink_module_web/components/app_bar.dart';
import 'package:gymlink_module_web/components/heading.dart';
class BasketPage extends StatelessWidget { class BasketPage extends StatelessWidget {
const BasketPage({ const BasketPage({
@@ -6,16 +8,16 @@ class BasketPage extends StatelessWidget {
}); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return const Scaffold(
appBar: AppBar( appBar: GymLinkAppBar(),
leading: IconButton( body: Column(
icon: const Icon(Icons.arrow_back), children: [
onPressed: () => Navigator.pop(context), GymLinkHeader(title: 'Корзина'),
), Center(
title: const Text('Корзина'),
),
body: const Center(
child: Text('Корзина'), child: Text('Корзина'),
)); ),
],
),
);
} }
} }

View File

@@ -1,4 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gymlink_module_web/components/app_bar.dart';
import 'package:gymlink_module_web/components/heading.dart';
//TODO: Сделать получение инфы через объект //TODO: Сделать получение инфы через объект
class DetailPage extends StatelessWidget { class DetailPage extends StatelessWidget {
@@ -18,14 +20,12 @@ class DetailPage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: const GymLinkAppBar(),
leading: IconButton( body: Column(mainAxisAlignment: MainAxisAlignment.start, children: [
icon: const Icon(Icons.arrow_back), GymLinkHeader(title: '$name - $id'),
onPressed: () => Navigator.pop(context), Expanded(
), child: SingleChildScrollView(
title: Text('$name - $id'), child: Padding(
),
body: Padding(
padding: const EdgeInsets.all(20), padding: const EdgeInsets.all(20),
child: SizedBox( child: SizedBox(
width: MediaQuery.sizeOf(context).width, width: MediaQuery.sizeOf(context).width,
@@ -35,7 +35,8 @@ class DetailPage extends StatelessWidget {
children: [ children: [
image, image,
Padding( Padding(
padding: const EdgeInsetsDirectional.fromSTEB(0, 60, 60, 60), padding:
const EdgeInsetsDirectional.fromSTEB(0, 30, 60, 60),
child: SizedBox( child: SizedBox(
width: 340, width: 340,
height: MediaQuery.sizeOf(context).height, height: MediaQuery.sizeOf(context).height,
@@ -46,8 +47,8 @@ class DetailPage extends StatelessWidget {
borderRadius: BorderRadius.circular(16), borderRadius: BorderRadius.circular(16),
), ),
child: Padding( child: Padding(
padding: padding: const EdgeInsetsDirectional.fromSTEB(
const EdgeInsetsDirectional.fromSTEB(20, 15, 10, 15), 20, 15, 10, 15),
child: Text( child: Text(
description, description,
style: Theme.of(context).textTheme.bodyMedium, style: Theme.of(context).textTheme.bodyMedium,
@@ -59,7 +60,8 @@ class DetailPage extends StatelessWidget {
Align( Align(
alignment: const AlignmentDirectional(0, -1), alignment: const AlignmentDirectional(0, -1),
child: Padding( child: Padding(
padding: const EdgeInsetsDirectional.fromSTEB(0, 60, 0, 0), padding:
const EdgeInsetsDirectional.fromSTEB(0, 60, 0, 0),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
@@ -70,7 +72,8 @@ class DetailPage extends StatelessWidget {
ElevatedButton( ElevatedButton(
onPressed: () => {}, onPressed: () => {},
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).primaryColor, backgroundColor:
Theme.of(context).primaryColor,
shape: const RoundedRectangleBorder( shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all( borderRadius: BorderRadius.all(
Radius.circular(50), Radius.circular(50),
@@ -89,6 +92,9 @@ class DetailPage extends StatelessWidget {
), ),
), ),
), ),
),
),
]),
); );
} }
} }

View File

@@ -1,4 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gymlink_module_web/components/app_bar.dart';
import 'package:gymlink_module_web/components/heading.dart';
class HistoryPage extends StatelessWidget { class HistoryPage extends StatelessWidget {
const HistoryPage({ const HistoryPage({
@@ -6,16 +8,14 @@ class HistoryPage extends StatelessWidget {
}); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return const Scaffold(
appBar: AppBar( appBar: GymLinkAppBar(),
leading: IconButton( body: Column(mainAxisAlignment: MainAxisAlignment.start, children: [
icon: const Icon(Icons.arrow_back), GymLinkHeader(title: 'История заказов'),
onPressed: () => Navigator.pop(context), Center(
),
title: const Text('История заказов'),
),
body: const Center(
child: Text('История заказов'), child: Text('История заказов'),
)); )
]),
);
} }
} }