feat: add app bar with dynamic header
parent
78c2415391
commit
345a9e0d4e
|
@ -7,6 +7,7 @@
|
|||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
|
@ -491,6 +492,11 @@ __pycache__/
|
|||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
#Dart Tools
|
||||
package_config.json
|
||||
package_config_subset
|
||||
version
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class CardComponent extends StatelessWidget {
|
||||
final String title;
|
||||
final String description;
|
||||
|
||||
const CardComponent({super.key, required this.title, required this.description});
|
||||
const CardComponent({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -16,11 +14,6 @@ class CardComponent extends StatelessWidget {
|
|||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(title, style: const TextStyle(fontSize: 24.0)),
|
||||
const SizedBox(height: 8.0),
|
||||
Text(description, style: const TextStyle(fontSize: 16.0)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -11,11 +11,15 @@ class NavigationScreen extends StatefulWidget {
|
|||
|
||||
class NavigationScreenState extends State<NavigationScreen> {
|
||||
int _selectedIndex = 0;
|
||||
final _pages = ["Page 1", "Page 2", "Page 3"];
|
||||
String _selectedPage = "Page 1";
|
||||
|
||||
final PageController _pageController = PageController(initialPage: 0);
|
||||
|
||||
void _onItemTapped(int index) {
|
||||
setState(() {
|
||||
_selectedIndex = index;
|
||||
_selectedPage = _pages[index];
|
||||
_pageController.animateToPage(index,
|
||||
duration: const Duration(milliseconds: 300), curve: Curves.easeInOut);
|
||||
});
|
||||
|
@ -24,11 +28,15 @@ class NavigationScreenState extends State<NavigationScreen> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(_selectedPage),
|
||||
),
|
||||
body: PageView(
|
||||
controller: _pageController,
|
||||
children: _widgetOptions,
|
||||
onPageChanged: (int index) {
|
||||
setState(() {
|
||||
_selectedPage = _pages[index];
|
||||
_selectedIndex = index;
|
||||
});
|
||||
},
|
||||
|
@ -57,30 +65,21 @@ class NavigationScreenState extends State<NavigationScreen> {
|
|||
static final List<Widget> _widgetOptions = <Widget>[
|
||||
Swiper(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return const CardComponent(
|
||||
title: 'Page 1',
|
||||
description: 'This is page 1',
|
||||
);
|
||||
return const CardComponent();
|
||||
},
|
||||
itemCount: 1,
|
||||
loop: false,
|
||||
),
|
||||
Swiper(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return const CardComponent(
|
||||
title: 'Page 2',
|
||||
description: 'This is page 2',
|
||||
);
|
||||
return const CardComponent();
|
||||
},
|
||||
itemCount: 1,
|
||||
loop: false,
|
||||
),
|
||||
Swiper(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return const CardComponent(
|
||||
title: 'Page 3',
|
||||
description: 'This is page 3',
|
||||
);
|
||||
return const CardComponent();
|
||||
},
|
||||
itemCount: 1,
|
||||
loop: false,
|
||||
|
|
Loading…
Reference in New Issue