Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix/#57] 다이얼로그 디자인 및 동작 수정 #94

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions assets/icons/3d_img/3d_coffee.svg

This file was deleted.

Binary file removed assets/icons/3d_img/3d_fire.png
Binary file not shown.
9 changes: 0 additions & 9 deletions assets/icons/3d_img/3d_fire.svg

This file was deleted.

9 changes: 0 additions & 9 deletions assets/icons/3d_img/3d_heart.svg

This file was deleted.

Binary file removed assets/icons/3d_img/3d_rocket.png
Binary file not shown.
Binary file added assets/icons/3d_img/calendar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/3d_img/caution.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added assets/icons/3d_img/fire.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added assets/icons/3d_img/trash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions lib/common/navigator/bottom_navigation_bar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:provider/provider.dart';
import 'package:cogo/common/navigator/bottom_navigation_bar_view_model.dart';
import 'package:flutter_svg/flutter_svg.dart';

class ScaffoldWithNestedNavigation extends StatelessWidget {
const ScaffoldWithNestedNavigation({
Key? key,
required this.navigationShell,
}) : super(key: key ?? const ValueKey('ScaffoldWithNestedNavigation'));

final StatefulNavigationShell navigationShell;

void _goBranch(int index) {
navigationShell.goBranch(
index,
initialLocation: index == navigationShell.currentIndex,
);
}

Widget _buildIcon(String assetPath, bool isSelected) {
return ColorFiltered(
colorFilter: ColorFilter.mode(
isSelected ? Colors.white : const Color(0xFF626262),
BlendMode.srcIn,
),
child: SvgPicture.asset(assetPath, width: 26, height: 26),
);
}

@override
Widget build(BuildContext context) {
return Consumer<BottomNavigationViewModel>(
builder: (context, controller, child) => Scaffold(
body: navigationShell,
bottomNavigationBar: Container(
child: ClipRRect(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(13.0),
topRight: Radius.circular(13.0),
),
child: BottomNavigationBar(
currentIndex: navigationShell.currentIndex,
onTap: (index) {
controller.setIndex(index, context); // setIndex 호출
},
backgroundColor: Colors.black,
selectedItemColor: Colors.white,
unselectedItemColor: const Color(0xFF626262),
selectedLabelStyle: const TextStyle(
fontFamily: 'PretendardRegular',
fontSize: 12,
),
unselectedLabelStyle: const TextStyle(
fontFamily: 'PretendardRegular',
fontSize: 12,
),
items: [
BottomNavigationBarItem(
icon: _buildIcon(
'assets/icons/navigator/home.svg',
navigationShell.currentIndex == 0,
),
label: '홈',
),
BottomNavigationBarItem(
icon: _buildIcon(
'assets/icons/navigator/cogo.svg',
navigationShell.currentIndex == 1,
),
label: '코고',
),
BottomNavigationBarItem(
icon: _buildIcon(
'assets/icons/navigator/mypage.svg',
navigationShell.currentIndex == 2,
),
label: 'MY',
),
],
),
),
),
),
);
}
}
85 changes: 85 additions & 0 deletions lib/common/navigator/bottom_navigation_bar_view_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import 'package:cogo/common/enums/role.dart';
import 'package:cogo/data/repository/local/secure_storage_repository.dart';
import 'package:cogo/features/home/home_view_model.dart';
import 'package:cogo/features/mypage/profile_management/mentor_introduction_screen.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:provider/provider.dart';
import 'package:cogo/common/widgets/widgets.dart';

class BottomNavigationViewModel extends ChangeNotifier {
final SecureStorageRepository _secureStorage = SecureStorageRepository();
String? role;

final GoRouter goRouter;
int _selectedIndex = 0;

int get selectedIndex => _selectedIndex;

BottomNavigationViewModel(this.goRouter) {
_loadPreferences();
}

void _loadPreferences() async {
role = await _secureStorage.readRole();
}

void setIndex(int index, BuildContext context) {
// HomeViewModel에 접근해서 role과 isIntroductionComplete 값 확인
final homeViewModel = Provider.of<HomeViewModel>(context, listen: false);

if (index == 1 &&
role == 'MENTOR' &&
!homeViewModel.isIntroductionComplete) {
// 조건이 만족하면 다이얼로그를 띄움
_showMentorProfileDialog(context);
} else {
// 페이지 이동 처리
_selectedIndex = index;
notifyListeners();

switch (index) {
case 0:
context.go('/home');
break;
case 1:
context.go('/cogo');
break;
case 2:
context.go('/mypage');
break;
}
}
}

/// 다이얼로그를 띄우는 함수
void _showMentorProfileDialog(BuildContext context) {
showDialog(
context: context,
builder: (BuildContext context) {
return BasicDialog(
title: "멘토 활동을 시작하려면\n프로필 작성을 완료해주세요",
subtitle: '입력하신 정보는 하단의 MY에서 수정이 가능해요',
imagePath: 'assets/icons/3d_img/heart.png',
buttonText: '멘토 프로필 작성하기',
onPressed: () => Navigator.of(context).push(_createRoute()),
);
},
);
}

Route _createRoute() {
return PageRouteBuilder(
pageBuilder: (context, animation, secondaryAnimation) =>
const MentorIntroductionScreen(),
transitionsBuilder: (context, animation, secondaryAnimation, child) {
var tween = Tween(begin: const Offset(0.0, 1.0), end: Offset.zero)
.chain(CurveTween(curve: Curves.ease));
return SlideTransition(
position: animation.drive(tween),
child: child,
);
},
);
}
}
89 changes: 0 additions & 89 deletions lib/common/navigator/view/bottom_navigation_bar.dart

This file was deleted.

This file was deleted.

Loading