-
Notifications
You must be signed in to change notification settings - Fork 1
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
๐ง ๋ก๊ทธ์์ ์ ํธํฐ ํ ํญ์ผ๋ก ์ด๋์ํค๋ ๋ก์ง ์ถ๊ฐ ๋ฐ ํ์ ๊ฐ์ ์ ์ฒด ๋์ ๋ฒํผ ์๋ฌ ์์ #9
Conversation
late int _selectedIndex = _tabs.indexOf(widget.tab); | ||
@override | ||
Widget build(BuildContext context) { | ||
int selectedIndex = ref.watch(navigationSelectedIndexProvider); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋ง์ดํ์ด์ง ํญ์์ ๋ก๊ทธ์์ ์ selectedIndex๋ฅผ ๋๊ฒจ์ฃผ์ด์ผ ํ ํญ์ผ๋ก ์ด๋ํ ์ ์๊ธฐ ๋๋ฌธ์ ์์ ฏ ๊ฐ ํด๋น ๋ฐ์ดํฐ๋ฅผ ๊ณต์ ํ๊ธฐ ์ํด ์ํ ๊ด๋ฆฌ ์๋ฃจ์ ์ ์ฌ์ฉํ์ด์.
setState(() { | ||
// ์ ์ ๊ฐ ํด๋ฆญํ index๋ฅผ navigationSelectedIndexProvider์ state์ ํ ๋น | ||
ref.read(navigationSelectedIndexProvider.notifier).state = index; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onTap ์์ ์ ์ ๊ฐ ํด๋ฆญํ index๋ฅผ ๋ฐ์ navigationSelectedIndexProvider๊ฐ ๊ด๋ฆฌํ๊ณ ์๋ selectedIndex ๊ฐ์ ์ ๋ฐ์ดํธ ํด์ฃผ๋ฉด์ setStateํจ์๋ฅผ ํธ์ถํด ํ๋ฉด์ ๋ค์ ๊ทธ๋ ค์ -> ์ ์ ๊ฐ ํด๋ฆญํ ํญ์ ํ๋ฉด์ผ๋ก ์ด๋
'profile', | ||
]; | ||
|
||
final tab = ref.watch(tabsProvider); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
router.dart์์ MainNavigationScreen์ผ๋ก ๋๊ธฐ๋ tab ๊ฐ์ tabsProvider๋ก ๊ด๋ฆฌํด์.
|
||
final tab = ref.watch(tabsProvider); | ||
|
||
int selectedIndex = tabs.indexOf(tab); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๊ทธ๋ ๊ฒ ๋ฐ์ tab ๊ฐ์ tabs ๋ผ๋ ๋ฆฌ์คํธ๋ฅผ ์ํํ๋ฉด์ ๊ฐ์ ๊ฐ์ ์ฐพ์ผ๋ฉด ๋ฆฌ์คํธ์์ ํด๋น ๊ฐ์ด ์์นํ ๊ณณ(index)๋ฅผ selectedIndex๋ก ์ฑ ์คํ ํ ์ด๊ธฐ ๊ฐ์ ํ ๋นํด์.
@@ -0,0 +1,3 @@ | |||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | |||
|
|||
final tabsProvider = StateProvider<String>((ref) => 'tuti'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ฑ ์คํ ์ ํ๋ฉด ์ง์ ์ ์ tuti ํ๋ฉด์ด๊ธฐ ๋๋ฌธ์ ์ด๊ธฐ ๊ฐ์ tuti๋ก ์ค์ ํด์คฌ์ด์.
style: Theme.of(context) | ||
.textTheme | ||
.bodyMedium! | ||
.copyWith(fontWeight: FontWeight.w600), | ||
controller: _nameController, | ||
onEditingComplete: () { | ||
if (_name.isNotEmpty) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TextField์ ํฐํธ๊ฐ ๋๋ฌด ์ปค์ textTheme์ bodyMedium์ผ๋ก ํต์ผ
}); | ||
ref | ||
.read(navigationSelectedIndexProvider.notifier) | ||
.state = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ ์ ๊ฐ ๋ก๊ทธ์์ ๋ฒํผ์ ํด๋ฆญ ์ ํ ํฐ์ ์ ๊ฑฐํ๊ณ navigationSelectedIndexProvider์ ์ํ๋ฅผ 1(tuti ํญ index)๋ก ๋ณ๊ฒฝํ์ด์
-> mainNavigationScreen์ build ๋ด watch๋ก ์ฒญ์ทจ์ค์ธ navigationSelectedIndexProvider๊ฐ ๋ณ๊ฒฝ์ ๊ฐ์งํ๊ณ reBuildํ์ฌ ํธํฐ ํญ์ผ๋ก ์ด๋ํ๊ฒ ์์ ํ์ด์.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ํธํฐ ํ ํ๋ฉด ๋ฉ์ธ ๋ฐฐ๋ ์ถ๊ฐ ๋ฐ ํด๋ฆญ ์ ํผ์ค๋ ๋ธ๋๋ฉ ํ๋ฉด์ผ๋ก ์ด๋ํ๋๋ก ์ค์
flexibleSpace: const FlexibleSpaceBar( | ||
background: TuTiBanner(), | ||
), | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
95 ~ 100๋ฒ์งธ ์ฝ๋ ์ค๋ช
์ ์ ๊ฐ ์คํฌ๋กค ์ ๋ฉ์ธ ๋ฐฐ๋๋ฅผ ์จ๊ธฐ๋๋ก ํ๊ธฐ ์ํด CustomScrollView ์ฌ์ฉํ์ด์.
SliverAppBar์ pinned(์คํฌ๋กค ํด๋ ์๋จ์ ๊ณ ์ ), floating(์ ์ ๊ฐ ์คํฌ๋กค์ ์๋ก ์ฌ๋ฆด ์ ๋ฐ๋ก ๋ฉ์ธ ๋ฐฐ๋๊ฐ ํ์ด๋์ด) ์ false๋ก ์ค์ ํ์ด์.
return MainNavigationScreen(tab: tab); | ||
String tab = state.params['tab'] ?? 'tuti'; | ||
ref.read(tabsProvider.notifier).state = tab; | ||
return const MainNavigationScreen(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- ์ ์ ๊ฐ ์ ํํ tab๊ฐ์ ๋์ ์ผ๋ก ๋ณ์ tab์ ํ ๋น
- tabsProvider์ state์ ๋ณ์ tab์ด ๊ฐ์ง ๊ฐ ํ ๋น
1,2๋ก ์ธํด MainNavigationScreen์์ ์ธ์๋ฅผ ๋ฐ์ง ์์๋ ๋๊ธฐ ๋๋ฌธ์ tab ํ๋กํผํฐ ์ ๊ฑฐ.
Title
๐ง ๋ก๊ทธ์์ ์ ํธํฐ ํ ํญ์ผ๋ก ์ด๋์ํค๋ ๋ก์ง ์ถ๊ฐ
What type of PR is this?
Description
Related Issue number and link
Mobile & Desktop Screenshots/Recordings
default.mp4
Checklist:
To Reviewers
build ๋ฉ์๋์์ ํ ํฐ ์ธ์ฆ ๋ฑ์ ์ฒดํฌํด๋ ๋๋์ง ๊ถ๊ธํฉ๋๋ค..!