Skip to content

Commit

Permalink
refactor : make app bar module
Browse files Browse the repository at this point in the history
  • Loading branch information
cho4u4o committed Oct 8, 2024
1 parent 148172d commit 48f43d6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 83 deletions.
49 changes: 2 additions & 47 deletions lib/screens/products/item_list_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:saphy/utils/colors.dart';
import 'package:saphy/utils/textstyles.dart';
import 'package:saphy/widgets/app_bar.dart';
import 'package:saphy/widgets/product_card.dart';
import 'package:dio/dio.dart';
import 'package:saphy/models/product.dart';
Expand Down Expand Up @@ -59,10 +60,9 @@ class _ItemListPageState extends State<ItemListPage> {
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xfff4f4f4),
appBar: _appBar(),
appBar: TopAppBar(label: widget.name),
body: CustomScrollView(
slivers: [
_buildHeader(),
const SliverToBoxAdapter(
child: SizedBox(height: 10),
),
Expand All @@ -73,51 +73,6 @@ class _ItemListPageState extends State<ItemListPage> {
);
}

AppBar _appBar() {
return AppBar(
automaticallyImplyLeading: false,
backgroundColor: altWhite,
title: Padding(
padding: const EdgeInsets.only(top: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: const Icon(
Icons.arrow_back_ios,
size: 25,
),
onPressed: () {
Navigator.pop(context);
},
),
IconButton(
icon: const Icon(
Icons.search,
size: 25,
),
onPressed: () {},
),
],
),
),
);
}

SliverToBoxAdapter _buildHeader() {
return SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 30.0,
),
child: Text(
widget.name,
style: titleText(),
),
),
);
}

SliverPadding _buildSorter() {
return SliverPadding(
padding: const EdgeInsets.symmetric(horizontal: 30),
Expand Down
21 changes: 2 additions & 19 deletions lib/screens/products/liked_list_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:saphy/models/product.dart';
import 'package:saphy/utils/textstyles.dart';
import 'package:saphy/widgets/product_card.dart';
import 'package:saphy/utils/colors.dart';
import 'package:saphy/widgets/app_bar.dart';

class LikedListPage extends StatefulWidget {
const LikedListPage({super.key});
Expand All @@ -19,27 +20,9 @@ class _LikedListPageState extends State<LikedListPage> {

@override
Widget build(BuildContext context) {
var screenWidth = MediaQuery.of(context).size.width;
return Scaffold(
backgroundColor: const Color(0xfff4f4f4),
appBar: AppBar(
backgroundColor: altWhite,
title: Padding(
padding: const EdgeInsets.only(top: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
IconButton(
icon: const Icon(Icons.arrow_back_ios, size: 25),
onPressed: () {},
),
SizedBox(height: 50, width: screenWidth - 150),
IconButton(
icon: const Icon(Icons.search, size: 25), onPressed: () {}),
],
),
),
),
appBar: const TopAppBar(label: "찜 목록"),
body: CustomScrollView(
slivers: [
SliverPadding(
Expand Down
47 changes: 30 additions & 17 deletions lib/widgets/app_bar.dart
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
import 'package:flutter/material.dart';
import 'package:saphy/utils/colors.dart';
import 'package:saphy/utils/textstyles.dart';

class TopAppBar extends StatelessWidget implements PreferredSizeWidget {
final AppBar? appBar;
const TopAppBar({super.key, this.appBar});
final String? label;
const TopAppBar({super.key, this.appBar, this.label});

@override
Widget build(BuildContext context) {
return AppBar(
backgroundColor: Colors.white,
title: Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Image.asset(
"assets/images/SaphyLogoSmall.png",
height: 24,
),
),
centerTitle: false,
actions: [
Padding(
padding: const EdgeInsets.only(right: 20.0),
child: IconButton(
icon: const Icon(Icons.notifications_outlined),
toolbarHeight: 70,
automaticallyImplyLeading: false,
backgroundColor: altWhite,
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: const Icon(
Icons.arrow_back_ios,
size: 25,
),
onPressed: () {
Navigator.pop(context);
},
),
Text(
label ?? "",
style: titleText(),
),
IconButton(
icon: const Icon(
Icons.search,
size: 25,
),
onPressed: () {},
),
),
],
],
),
);
}

Expand Down

0 comments on commit 48f43d6

Please sign in to comment.