Skip to content

Commit

Permalink
Merge pull request #5 from team-balt/feature/sleeping
Browse files Browse the repository at this point in the history
Create Out Sleeping Screen
  • Loading branch information
priverg authored Nov 25, 2024
2 parents 2c69888 + 4262cc3 commit 8e5f0d7
Show file tree
Hide file tree
Showing 31 changed files with 1,602 additions and 56 deletions.
4 changes: 3 additions & 1 deletion lib/component/appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import 'package:flutter/material.dart';
class EasierDodamDefaultAppbar extends StatelessWidget {
final String title;
final Function() onPlusClick;
final Color colors;

const EasierDodamDefaultAppbar({
super.key,
required this.title,
required this.onPlusClick,
this.colors = EasierDodamColors.gray600,
});

@override
Expand Down Expand Up @@ -42,7 +44,7 @@ class EasierDodamDefaultAppbar extends StatelessWidget {
height: 24,
child: Image.asset(
"assets/images/ic_plus.png",
color: EasierDodamColors.gray600,
color: colors,
),
),
),
Expand Down
94 changes: 50 additions & 44 deletions lib/component/bottom_navigation_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,48 +13,51 @@ class EasierDodamBottomNavigationBar extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Container(
height: 63,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.grey.shade100,
blurRadius: 10,
offset: Offset(0, -15),
),
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
_buildNavItem(
context,
icon: 'assets/images/ic_bed.svg',
label: '외박',
index: 0,
),
_buildNavItem(
context,
icon: 'assets/images/ic_door_open.svg',
label: '외출',
index: 1,
),
_buildNavItem(
context,
icon: 'assets/images/ic_moon_plus.svg',
label: '심야자습',
index: 3,
),
_buildNavItem(
context,
icon: 'assets/images/ic_gear.svg',
label: '설정',
index: 2,
),

],
return SafeArea(
top: false,
child: Container(
height: 60,
padding: const EdgeInsets.symmetric(horizontal: 8),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.grey.shade300,
blurRadius: 10,
offset: const Offset(0, -5),
),
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
_buildNavItem(
context,
icon: 'assets/images/ic_bed.svg',
label: '외박',
index: 0,
),
_buildNavItem(
context,
icon: 'assets/images/ic_door_open.svg',
label: '외출',
index: 1,
),
_buildNavItem(
context,
icon: 'assets/images/ic_moon_plus.svg',
label: '심야자습',
index: 3,
),
_buildNavItem(
context,
icon: 'assets/images/ic_gear.svg',
label: '설정',
index: 2,
),
],
),
),
);
}
Expand All @@ -72,14 +75,17 @@ class EasierDodamBottomNavigationBar extends StatelessWidget {
icon,
height: isSelected ? 30 : 24,
width: isSelected ? 30 : 24,
color: isSelected ? Colors.blue : Colors.grey,
colorFilter: ColorFilter.mode(
isSelected ? Colors.blue : Colors.grey,
BlendMode.srcIn,
),
),
const SizedBox(height: 4),
Text(
label,
style: TextStyle(
color: isSelected ? Colors.blue : Colors.grey,
fontSize: isSelected ? 14 : 12,
fontSize: isSelected ? 13 : 12,
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
),
),
Expand Down
7 changes: 3 additions & 4 deletions lib/component/textfield.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import 'package:easier_dodam/component/theme/style.dart';
import 'package:flutter/material.dart';

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

final String? labelText;
final String? hintText;
final String? supportText;
final FocusNode? focusNode;
final TextEditingController? controller;
final bool obscureText;
final TextInputType? keyboardType;

const EasierDodamTextField({
super.key,
Expand All @@ -20,6 +19,7 @@ class EasierDodamTextField extends StatefulWidget {
this.focusNode,
this.controller,
this.obscureText = false,
this.keyboardType, // 추가된 부분
});

@override
Expand All @@ -32,7 +32,6 @@ class _EasierDodamTextFieldState extends State<EasierDodamTextField> {

@override
void initState() {
// TODO: implement initState
super.initState();
_focusNode = widget.focusNode ?? FocusNode();
_controller = widget.controller ?? TextEditingController();
Expand All @@ -43,7 +42,6 @@ class _EasierDodamTextFieldState extends State<EasierDodamTextField> {

@override
void dispose() {
// TODO: implement dispose
if (widget.controller == null) {
_controller.dispose();
}
Expand Down Expand Up @@ -79,6 +77,7 @@ class _EasierDodamTextFieldState extends State<EasierDodamTextField> {
textAlignVertical: TextAlignVertical.center,
cursorColor: EasierDodamColors.primary300,
obscureText: widget.obscureText,
keyboardType: widget.keyboardType, // 추가된 부분
decoration: InputDecoration(
hintText: widget.hintText,
hintStyle: EasierDodamStyles.label1.copyWith(height: 1.3),
Expand Down
49 changes: 49 additions & 0 deletions lib/feature/logout/item/setting_item.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import 'package:flutter/material.dart';

class SettingList extends StatelessWidget {
final String title;
final String trailing;

const SettingList({
Key? key,
required this.title,
required this.trailing,
}) : super(key: key);

@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 16.0),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12.0),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
offset: const Offset(0, 4),
blurRadius: 8,
),
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
title,
style: const TextStyle(
fontSize: 16,
color: Colors.black,
),
),
Text(
trailing,
style: const TextStyle(
fontSize: 16,
color: Colors.black54,
),
),
],
),
);
}
}
120 changes: 120 additions & 0 deletions lib/feature/logout/logout.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import '../../component/appbar.dart';
import '../../component/theme/color.dart';
import '../../component/bottom_navigation_bar.dart';
import '../../feature/login/login_navigation.dart';
import '../../feature/night_study/night_study_navigation.dart';
import '../../feature/out/out_navigation.dart';
import '../../feature/out_sleeping/out_sleeping_navigation.dart';
import '../logout/logout_viewmodel.dart';
import 'item/setting_item.dart';

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

@override
State<SettingScreen> createState() => _SettingScreenState();
}

class _SettingScreenState extends State<SettingScreen> {
int _selectedIndex = 2;

void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;

switch (index) {
case 0:
Navigator.pushReplacementNamed(context, outSleepingRoute);
break;
case 1:
Navigator.pushReplacementNamed(context, outRoute);
break;
case 2:
break;
case 3:
Navigator.pushReplacementNamed(context, nightStudyRoute);
break;
}
});
}

@override
Widget build(BuildContext context) {
final viewModel = Provider.of<SettingViewModel>(context);

return Scaffold(
appBar: PreferredSize(
preferredSize: const Size.fromHeight(60),
child: EasierDodamDefaultAppbar(
title: "설정",
colors: EasierDodamColors.staticWhite,
onPlusClick: () {},
),
),
body: Column(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SettingList(
title: '앱 버전',
trailing: 'v1.00',
),
const SizedBox(height: 24),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
offset: const Offset(0, 4),
blurRadius: 8,
),
],
),
child: SizedBox(
width: double.infinity,
height: 56.0,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: EasierDodamColors.primary300,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
),
),
onPressed: () async {
final success = await viewModel.logout();
if (success) {
Navigator.pushReplacementNamed(context, loginRoute);
}
},
child: const Text(
'로그아웃',
style: TextStyle(
color: EasierDodamColors.staticWhite,
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
),
),
],
),
),
),
],
),
bottomNavigationBar: EasierDodamBottomNavigationBar(
selectedIndex: _selectedIndex,
onItemTapped: _onItemTapped,
),
);
}
}
1 change: 1 addition & 0 deletions lib/feature/logout/logout_navigation.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const logoutRoute = "logout";
11 changes: 11 additions & 0 deletions lib/feature/logout/logout_viewmodel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:flutter/cupertino.dart';

import '../../local/storage_manager.dart';

class SettingViewModel with ChangeNotifier {
Future<bool> logout() async {
await StorageManager.deleteUserAccount();
notifyListeners();
return true;
}
}
3 changes: 0 additions & 3 deletions lib/feature/out_create/out_create.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ class _OutCreateScreenState extends State<OutCreateScreen> {
}

TimeOfDay adjustTimeOfDay(TimeOfDay time, {required int hoursToAdd}) {
// TimeOfDay를 DateTime으로 변환
final now = DateTime.now();
final timeAsDateTime = DateTime(
now.year,
Expand All @@ -163,11 +162,9 @@ TimeOfDay adjustTimeOfDay(TimeOfDay time, {required int hoursToAdd}) {
time.minute,
);

// 시간 증감
final adjustedTimeAsDateTime =
timeAsDateTime.add(Duration(hours: hoursToAdd));

// 다시 TimeOfDay로 변환
return TimeOfDay(
hour: adjustedTimeAsDateTime.hour,
minute: adjustedTimeAsDateTime.minute,
Expand Down
Loading

0 comments on commit 8e5f0d7

Please sign in to comment.