-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(#63): integrando vários conteúdos
- Loading branch information
1 parent
4cfd14f
commit 909579d
Showing
8 changed files
with
79 additions
and
14 deletions.
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
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
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,6 @@ | ||
import 'package:aranduapp/ui/pages_content/viewmodel/page_content_viewmodel.dart'; | ||
import 'package:get_it/get_it.dart'; | ||
|
||
void setupPagesContentDI() { | ||
GetIt.I.registerFactory(() => PageContentViewmodel()); | ||
} |
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,43 @@ | ||
import 'package:aranduapp/ui/content/view/content_view.dart'; | ||
import 'package:aranduapp/ui/pages_content/viewmodel/page_content_viewmodel.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:get_it/get_it.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
class PagesContentView extends StatelessWidget { | ||
final List<String> listContent; | ||
|
||
const PagesContentView({super.key, required this.listContent}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ChangeNotifierProvider<PageContentViewmodel>.value( | ||
value: GetIt.instance<PageContentViewmodel>(), | ||
child: PagesContentScreen(listContent: listContent), | ||
); | ||
} | ||
} | ||
|
||
class PagesContentScreen extends StatelessWidget { | ||
final List<String> listContent; | ||
|
||
final PageController _pageViewController = PageController(); | ||
|
||
PagesContentScreen({super.key, required this.listContent}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
PageContentViewmodel viewModel = Provider.of<PageContentViewmodel>(context); | ||
|
||
return Stack( | ||
children: [ | ||
PageView( | ||
controller: _pageViewController, | ||
onPageChanged: (index) => viewModel.selectedIndex, | ||
children: List.generate(listContent.length, (index) { | ||
return ContentView(contentID: listContent[index]); | ||
})), | ||
], | ||
); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
lib/ui/pages_content/viewmodel/page_content_viewmodel.dart
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,14 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class PageContentViewmodel extends ChangeNotifier { | ||
int _selectedIndex = 0; | ||
|
||
int get selectedIndex => _selectedIndex; | ||
|
||
void changeTab(int index) { | ||
if (_selectedIndex != index) { | ||
_selectedIndex = index; | ||
notifyListeners(); | ||
} | ||
} | ||
} |
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,8 +1,8 @@ | ||
class TrailsModel { | ||
final String id; | ||
final String name; | ||
final String? contectId; | ||
final List<String>? contects; | ||
|
||
TrailsModel({required this.id, required this.name, this.contectId}); | ||
TrailsModel({required this.id, required this.name, this.contects}); | ||
} | ||
|
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
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