Skip to content

Commit

Permalink
Merge pull request #1 from Da-gather/default
Browse files Browse the repository at this point in the history
Feat: bottom navigation bar 구현
  • Loading branch information
Ujaa authored May 6, 2023
2 parents 1ce567e + 95fb578 commit 03b66b3
Show file tree
Hide file tree
Showing 13 changed files with 265 additions and 102 deletions.
8 changes: 8 additions & 0 deletions assets/icons/navigation/ic_chat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions assets/icons/navigation/ic_chat_filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions assets/icons/navigation/ic_home.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions assets/icons/navigation/ic_home_filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions assets/icons/navigation/ic_person.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions assets/icons/navigation/ic_person_filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 86 additions & 0 deletions lib/components/navigation_bar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import 'package:dagather_frontend/screens/account/screens/account_screen.dart';
import 'package:dagather_frontend/screens/chat/screens/chats_screen.dart';
import 'package:dagather_frontend/screens/home/screens/home_screen.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/flutter_svg.dart';

import '../utilities/colors.dart';

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

@override
State<BaseScaffold> createState() => _BaseScaffoldState();
}

class _BaseScaffoldState extends State<BaseScaffold> {
int _selectedIdx = 0;

final List<Widget> _screenList = [
const HomeScreen(),
const ChatsScreen(),
const AccountScreen(),
];

void _onItemTapped(int index) {
setState(() {
_selectedIdx = index;
});
}

@override
void initState() {
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: _screenList.elementAt(_selectedIdx),
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: _selectedIdx,
backgroundColor: Colors.white,
unselectedItemColor: AppColor.g400,
onTap: _onItemTapped,
showSelectedLabels: false,
showUnselectedLabels: false,
type: BottomNavigationBarType.fixed,
items: [
BottomNavigationBarItem(
icon: SvgPicture.asset(
width: 24.w,
'assets/icons/navigation/ic_home.svg',
),
activeIcon: SvgPicture.asset(
width: 24.w,
'assets/icons/navigation/ic_home_filled.svg',
),
label: 'home'),
BottomNavigationBarItem(
icon: SvgPicture.asset(
width: 24.w,
'assets/icons/navigation/ic_chat.svg',
),
activeIcon: SvgPicture.asset(
width: 24.w,
'assets/icons/navigation/ic_chat_filled.svg',
),
label: 'chat'),
BottomNavigationBarItem(
icon: SvgPicture.asset(
width: 24.w,
'assets/icons/navigation/ic_person.svg',
),
activeIcon: SvgPicture.asset(
width: 24.w,
'assets/icons/navigation/ic_person_filled.svg',
),
label: 'account'),
],
),
);
}
}
127 changes: 27 additions & 100 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import 'package:dagather_frontend/components/navigation_bar.dart';
import 'package:dagather_frontend/utilities/colors.dart';
import 'package:dagather_frontend/utilities/fonts.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

void main() {
runApp(const MyApp());
Expand All @@ -10,106 +14,29 @@ class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Homfdge Page'),
);
}
}

class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});

// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.

// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".

final String title;

@override
State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;

void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}

@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
return ScreenUtilInit(
designSize: const Size(390, 844),
builder: (context, child) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Da:gather',
theme: ThemeData(
fontFamily: pretendardFont,
primaryColor: AppColor.yellow4,
primaryColorLight: AppColor.yellow2,
scaffoldBackgroundColor: Colors.white,
dividerColor: Colors.transparent,
),
builder: (context, widget) {
return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
child: widget!,
);
},
home: child,
);
},
child: const BaseScaffold(),
);
}
}
12 changes: 12 additions & 0 deletions lib/screens/account/screens/account_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:flutter/material.dart';

class AccountScreen extends StatelessWidget {
const AccountScreen({super.key});

@override
Widget build(BuildContext context) {
return const Center(
child: Text("account"),
);
}
}
12 changes: 12 additions & 0 deletions lib/screens/chat/screens/chats_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:flutter/material.dart';

class ChatsScreen extends StatelessWidget {
const ChatsScreen({super.key});

@override
Widget build(BuildContext context) {
return const Center(
child: Text("chats"),
);
}
}
12 changes: 12 additions & 0 deletions lib/screens/home/screens/home_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:flutter/material.dart';

class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});

@override
Widget build(BuildContext context) {
return const Center(
child: Text("home"),
);
}
}
Loading

0 comments on commit 03b66b3

Please sign in to comment.