forked from stamp-team/chat-flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
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
ChangeNotifierの実装(メインページ) #16
Merged
Merged
Changes from 3 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b4aaa0c
ページごとにディレクトリを作成
thoth000 387cca8
ChangeNotifierクラスを定義
thoth000 f72e08d
mainController
thoth000 9044e30
talkController
thoth000 ebdf747
profileController
thoth000 3cafa59
ProfileEditPageのProviderを変更
thoth000 0cf5f17
もろもろ修正
thoth000 abcd197
homeController
thoth000 9179ad5
Providerをdi.dartでセット(仮)
thoth000 02f1e31
Futureの戻り値をvoidに変更
thoth000 e41481e
HomePage修正
thoth000 1ef3712
MainController
thoth000 4959e8f
メインページのコントローラ完成
thoth000 52cdb0c
MultiProviderをmainで作成
thoth000 53080e9
flutter format .
thoth000 61ce4a2
使わないdi.dartを削除
thoth000 7c87aa9
指摘部分の修正
thoth000 1e9cb92
別ファイルへの切り出し
thoth000 6b8e569
flutter format .
thoth000 ab57921
Merge branch 'master' into feature/13/main
thoth000 0002225
不要なaxis.verticalの除去
thoth000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class HomeController with ChangeNotifier{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,17 @@ | ||
import 'package:chat_flutter/ui/molecules/home/app_bar.dart'; | ||
import 'package:chat_flutter/ui/molecules/profile/app_bar.dart'; | ||
import 'package:chat_flutter/ui/molecules/talk/app_bar.dart'; | ||
import 'package:chat_flutter/ui/pages/home.dart'; | ||
import 'package:chat_flutter/ui/pages/profile.dart'; | ||
import 'package:chat_flutter/ui/pages/talk.dart'; | ||
import 'package:chat_flutter/ui/pages/main/home/home.dart'; | ||
import 'package:chat_flutter/ui/pages/main/main_controller.dart'; | ||
import 'package:chat_flutter/ui/pages/main/profile/profile.dart'; | ||
import 'package:chat_flutter/ui/pages/main/talk/talk.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
class MainPage extends StatefulWidget { | ||
@override | ||
_MainPageState createState() => _MainPageState(); | ||
} | ||
|
||
class _MainPageState extends State<MainPage> { | ||
int _currentIndex = 0; | ||
void changePage(int index) { | ||
setState( | ||
() => _currentIndex = index, | ||
); | ||
} | ||
|
||
class MainPage extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
final _mainController = Provider.of<MainController>(context); | ||
final List appBarList = [ | ||
HomePageAppBar(), | ||
TalkPageAppBar(), | ||
|
@@ -40,20 +31,21 @@ class _MainPageState extends State<MainPage> { | |
]; | ||
|
||
return Scaffold( | ||
appBar: appBarList[_currentIndex], | ||
backgroundColor: backgroundColor[_currentIndex], | ||
bottomNavigationBar: bottomNavigation(), | ||
body: pages[_currentIndex], | ||
appBar: appBarList[_mainController.currentIndex], | ||
backgroundColor: backgroundColor[_mainController.currentIndex], | ||
bottomNavigationBar: bottomNavigation(context), | ||
body: pages[_mainController.currentIndex], | ||
); | ||
} | ||
|
||
Widget bottomNavigation() { | ||
Widget bottomNavigation(BuildContext context) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 逆にここは他のファイルから参照されていなければprivateにして良さそうです 👌 |
||
final _mainController = Provider.of<MainController>(context); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 上に同じくprivateにする必要はなさそうですね 👌 |
||
return BottomNavigationBar( | ||
backgroundColor: Colors.white, | ||
type: BottomNavigationBarType.fixed, | ||
showSelectedLabels: false, | ||
showUnselectedLabels: false, | ||
currentIndex: _currentIndex, | ||
currentIndex: _mainController.currentIndex, | ||
items: [ | ||
BottomNavigationBarItem( | ||
icon: Icon( | ||
|
@@ -80,9 +72,9 @@ class _MainPageState extends State<MainPage> { | |
), | ||
), | ||
], | ||
onTap: (index) => setState( | ||
() => _currentIndex = index, | ||
), | ||
onTap: (index){ | ||
_mainController.changePage(index); | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class MainController with ChangeNotifier{ | ||
int currentIndex; | ||
MainController(){ | ||
currentIndex = 0; | ||
} | ||
|
||
void changePage(int index){ | ||
currentIndex = index; | ||
notifyListeners(); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class ProfileController with ChangeNotifier{ | ||
|
||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class ProfileEditController with ChangeNotifier{ | ||
|
||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class TalkController with ChangeNotifier{ | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
メソッド内で定義されたものはそもそもメソッド内のスコープでしか使用できないのでprivateにする必要はなさそうですね 👌