Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:news_flutter/utilities/styles.dart';
- class OnboardingScreen extends StatefulWidget {
- @override
- _OnboardingScreenState createState() => _OnboardingScreenState();
- }
- class _OnboardingScreenState extends State<OnboardingScreen> {
- final int _numPages = 3;
- final PageController _pageController = PageController(initialPage: 0);
- int _currentPage = 0;
- List<Widget> _buildPageIndicator() {
- List<Widget> list = [];
- for (int i = 0; i < _numPages; i++) {
- list.add(i == _currentPage ? _indicator(true) : _indicator(false));
- }
- return list;
- }
- Widget _indicator(bool isActive) {
- return AnimatedContainer(
- duration: Duration(milliseconds: 150),
- margin: EdgeInsets.symmetric(horizontal: 8.0),
- height: 8.0,
- width: isActive ? 24.0 : 16.0,
- decoration: BoxDecoration(
- color: isActive ? Colors.white : Color(0xFF7B51D3),
- borderRadius: BorderRadius.all(Radius.circular(12)),
- ),
- );
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- resizeToAvoidBottomPadding: false ,
- body: AnnotatedRegion<SystemUiOverlayStyle>(
- value: SystemUiOverlayStyle.light,
- child: Container(
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.topCenter,
- stops: [0.1, 0.4, 0.7, 0.9],
- colors: [
- Color(4278249078),
- Color(4278241363),
- Color(4278249078),
- Color(4278241363),
- ],
- ),
- ),
- child:
- Padding(
- padding: EdgeInsets.symmetric(vertical: 20.0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: <Widget>[
- _currentPage != _numPages - 1
- ? Container(
- alignment: Alignment.centerRight,
- child: FlatButton(
- onPressed: () {
- _pageController.nextPage(
- duration: Duration(milliseconds: 500),
- curve: Curves.ease,
- );
- },
- child: Text(
- 'Next',
- style: TextStyle(
- color: Colors.white,
- fontSize: 20.0,
- ),
- ),
- ),
- ) : Text(""),
- Container(
- height: 600.0,
- child: PageView(
- physics: ClampingScrollPhysics(),
- controller: _pageController,
- onPageChanged: (int page) {
- setState(() {
- _currentPage = page;
- });
- },
- children: <Widget>[
- Padding(
- padding: EdgeInsets.all(20.0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Center(
- child: Image(
- image: AssetImage(
- 'assets/images/onboarding0.png',
- ),
- height: 200.0,
- width: 200.0,
- ),
- ),
- SizedBox(height: 50.0),
- Text(
- 'Connect human\naround the world',
- style: kTitleStyle,
- ),
- SizedBox(height: 15.0),
- Text(
- 'Lorem ipsum dolor sit amet, consect adipiscing elit, sed do eiusmod tempor incididunt ut labore et.',
- style: kSubtitleStyle,
- ),
- ],
- ),
- ),
- Padding(
- padding: EdgeInsets.all(40.0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Center(
- child: Image(
- image: AssetImage(
- 'assets/images/onboarding1.png',
- ),
- height: 200.0,
- width: 200.0,
- ),
- ),
- SizedBox(height: 50.0),
- Text(
- 'Live your life smarter\nwith us!',
- style: kTitleStyle,
- ),
- SizedBox(height: 15.0),
- Text(
- 'Lorem ipsum dolor sit amet, consect adipiscing elit, sed do eiusmod tempor incididunt ut labore et.',
- style: kSubtitleStyle,
- ),
- ],
- ),
- ),
- Padding(
- padding: EdgeInsets.all(40.0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Center(
- child: Image(
- image: AssetImage(
- 'assets/images/onboarding2.png',
- ),
- height: 200.0,
- width: 200.0,
- ),
- ),
- SizedBox(height: 50.0),
- Text(
- 'Get a new experience\nof imagination',
- style: kTitleStyle,
- ),
- SizedBox(height: 15.0),
- Text(
- 'Lorem ipsum dolor sit amet, consect adipiscing elit, sed do eiusmod tempor incididunt ut labore et.',
- style: kSubtitleStyle,
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: _buildPageIndicator(),
- ),
- _currentPage != _numPages - 1
- ? Expanded(
- child: Align(
- alignment: FractionalOffset.bottomRight,
- child: FlatButton(
- onPressed: () {
- _pageController.nextPage(
- duration: Duration(milliseconds: 500),
- curve: Curves.ease,
- );
- },
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- mainAxisSize: MainAxisSize.min,
- children: <Widget>[
- Text(
- 'Next',
- style: TextStyle(
- color: Colors.white,
- fontSize: 22.0,
- ),
- ),
- SizedBox(width: 10.0),
- Icon(
- Icons.arrow_forward,
- color: Colors.white,
- size: 50.0,
- ),
- ],
- ),
- ),
- ),
- )
- : Text(''),
- ],
- ),
- ),
- ),
- ),
- bottomSheet: _currentPage == _numPages - 1
- ? Container(
- height: 100.0,
- width: double.infinity,
- color: Colors.white,
- child: GestureDetector(
- onTap: () => print('Get started'),
- child: Center(
- child: Padding(
- padding: EdgeInsets.only(bottom: 10.0),
- child: Text(
- 'Get started',
- style: TextStyle(
- color: Color(4278241363),
- fontSize: 20.0,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- ),
- ),
- )
- : Container(
- height: 100.0,
- width: double.infinity,
- decoration: BoxDecoration(
- gradient: LinearGradient(
- stops: [0.1, 0.4, 0.7, 0.9],
- colors: [
- Color(4278241363),
- Color(4278241363),
- Color(4278241363),
- Color(4278241363),
- ],
- ),
- ),
- child: GestureDetector(
- onTap: () => print('Get started'),
- child: Center(
- child: Padding(
- padding: EdgeInsets.only(bottom: 10.0),
- ),
- ),
- ),
- )
- ,
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement