Guest User

Untitled

a guest
Jul 8th, 2022
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 4.70 KB | None | 0 0
  1. class _IntroViewState extends State<IntroView> {
  2.  
  3.   final controller = PageController();
  4.   bool isLastPage = false;
  5.  
  6.  
  7.   @override
  8.   void initState() {
  9.     SystemChrome.setEnabledSystemUIMode(
  10.       SystemUiMode.manual,
  11.       overlays: [SystemUiOverlay.top],
  12.     );
  13.     super.initState();
  14.   }
  15.  
  16.   @override
  17.   void dispose() {
  18.     super.dispose();
  19.     controller.dispose();
  20.  
  21.   }
  22.  
  23.   @override
  24.   Widget build(BuildContext context) {
  25.     return Scaffold(
  26.       body: Container(
  27.         // padding: const EdgeInsets.only(bottom: 80),
  28.         child: PageView(
  29.           controller: controller,
  30.           onPageChanged: (index){
  31.             setState(()=> isLastPage = index == 2);
  32.           },
  33.           children: [
  34.             Container(
  35.               decoration: const BoxDecoration(
  36.                 image: DecorationImage(
  37.                   image: AssetImage("assets/images/intro1.jpg"),
  38.                   fit: BoxFit.cover,
  39.                   opacity: 0.8,
  40.                 ),
  41.               ),
  42.               child: Text("test"),
  43.  
  44.             ),
  45.             Container(
  46.               decoration: const BoxDecoration(
  47.                 image: DecorationImage(
  48.                   image: AssetImage("assets/images/intro1.jpg"),
  49.                   fit: BoxFit.cover,
  50.                   opacity: 0.8,
  51.                 ),
  52.               ),
  53.               child: Text("test"),
  54.  
  55.             ),
  56.             Container(
  57.               decoration: const BoxDecoration(
  58.                 image: DecorationImage(
  59.                   image: AssetImage("assets/images/intro1.jpg"),
  60.                   fit: BoxFit.cover,
  61.                   opacity: 0.8,
  62.                 ),
  63.               ),
  64.               child: Text("test"),
  65.  
  66.             ),
  67.           ],
  68.         ),
  69.       ),
  70.       bottomSheet: isLastPage
  71.         ? Column(
  72.           mainAxisAlignment: MainAxisAlignment.end,
  73.           children: [
  74.             Container(
  75.               margin: const EdgeInsets.only(left: 20,right: 20),
  76.               child: TextButton(
  77.                 style: TextButton.styleFrom(
  78.                   shape: RoundedRectangleBorder(
  79.                     borderRadius: BorderRadius.circular(50),
  80.                   ),
  81.                   primary: Colors.red,
  82.                   backgroundColor: Colors.white,
  83.                   minimumSize: const Size.fromHeight(60),
  84.                 ),
  85.                 onPressed: (){
  86.                   context.read<AuthBloc>().add(const AuthEventLogOut());
  87.                 },
  88.                 child: const Text(
  89.                   'Accedi',
  90.                   style: TextStyle(fontSize: 20),
  91.                 ),
  92.               ),
  93.             ),
  94.             Container(
  95.               margin: const EdgeInsets.all(20),
  96.               child: TextButton(
  97.                   style: TextButton.styleFrom(
  98.                     shape: RoundedRectangleBorder(
  99.                       borderRadius: BorderRadius.circular(50),
  100.                     ),
  101.                     primary: Colors.white,
  102.                     backgroundColor: Colors.red.shade700,
  103.                     minimumSize: const Size.fromHeight(60),
  104.                   ),
  105.                   onPressed: (){
  106.                     context.read<AuthBloc>().add(const AuthEventShouldRegister());
  107.                   },
  108.                   child: const Text(
  109.                     'Registrati',
  110.                     style: TextStyle(fontSize: 20),
  111.                   ),
  112.                 ),
  113.             ),
  114.  
  115.           ],
  116.         )
  117.         : Container(
  118.         padding: const EdgeInsets.symmetric(horizontal: 16),
  119.         decoration: BoxDecoration(
  120.           color: Colors.white,
  121.           borderRadius: BorderRadius.circular(50),
  122.         ),
  123.         margin: const EdgeInsets.all(20),
  124.  
  125.         height: 70,
  126.         child: Row(
  127.           mainAxisAlignment: MainAxisAlignment.spaceBetween,
  128.           children: [
  129.             TextButton(
  130.                 onPressed: (){
  131.                   controller.jumpToPage(2);
  132.                 },
  133.                 child: const Text("SKIP"),
  134.             ),
  135.             Center(
  136.               child: SmoothPageIndicator(
  137.                 controller: controller,
  138.                 count: 3,
  139.                 effect: const WormEffect(
  140.                   spacing: 16,
  141.                   dotColor: Colors.black26,
  142.                   activeDotColor: Colors.redAccent,
  143.                 ),
  144.               ),
  145.             ),
  146.             TextButton(
  147.               onPressed: (){
  148.                 controller.nextPage(
  149.                     duration: const Duration(milliseconds: 500),
  150.                     curve: Curves.easeInOut
  151.                 );
  152.               },
  153.               child: const Text("NEXT"),
  154.             )
  155.           ],
  156.         ),
  157.       ),
  158.     );
  159.   }
  160. }
  161.  
Advertisement
Add Comment
Please, Sign In to add comment