Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class _IntroViewState extends State<IntroView> {
- final controller = PageController();
- bool isLastPage = false;
- @override
- void initState() {
- SystemChrome.setEnabledSystemUIMode(
- SystemUiMode.manual,
- overlays: [SystemUiOverlay.top],
- );
- super.initState();
- }
- @override
- void dispose() {
- super.dispose();
- controller.dispose();
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Container(
- // padding: const EdgeInsets.only(bottom: 80),
- child: PageView(
- controller: controller,
- onPageChanged: (index){
- setState(()=> isLastPage = index == 2);
- },
- children: [
- Container(
- decoration: const BoxDecoration(
- image: DecorationImage(
- image: AssetImage("assets/images/intro1.jpg"),
- fit: BoxFit.cover,
- opacity: 0.8,
- ),
- ),
- child: Text("test"),
- ),
- Container(
- decoration: const BoxDecoration(
- image: DecorationImage(
- image: AssetImage("assets/images/intro1.jpg"),
- fit: BoxFit.cover,
- opacity: 0.8,
- ),
- ),
- child: Text("test"),
- ),
- Container(
- decoration: const BoxDecoration(
- image: DecorationImage(
- image: AssetImage("assets/images/intro1.jpg"),
- fit: BoxFit.cover,
- opacity: 0.8,
- ),
- ),
- child: Text("test"),
- ),
- ],
- ),
- ),
- bottomSheet: isLastPage
- ? Column(
- mainAxisAlignment: MainAxisAlignment.end,
- children: [
- Container(
- margin: const EdgeInsets.only(left: 20,right: 20),
- child: TextButton(
- style: TextButton.styleFrom(
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(50),
- ),
- primary: Colors.red,
- backgroundColor: Colors.white,
- minimumSize: const Size.fromHeight(60),
- ),
- onPressed: (){
- context.read<AuthBloc>().add(const AuthEventLogOut());
- },
- child: const Text(
- 'Accedi',
- style: TextStyle(fontSize: 20),
- ),
- ),
- ),
- Container(
- margin: const EdgeInsets.all(20),
- child: TextButton(
- style: TextButton.styleFrom(
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(50),
- ),
- primary: Colors.white,
- backgroundColor: Colors.red.shade700,
- minimumSize: const Size.fromHeight(60),
- ),
- onPressed: (){
- context.read<AuthBloc>().add(const AuthEventShouldRegister());
- },
- child: const Text(
- 'Registrati',
- style: TextStyle(fontSize: 20),
- ),
- ),
- ),
- ],
- )
- : Container(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(50),
- ),
- margin: const EdgeInsets.all(20),
- height: 70,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- TextButton(
- onPressed: (){
- controller.jumpToPage(2);
- },
- child: const Text("SKIP"),
- ),
- Center(
- child: SmoothPageIndicator(
- controller: controller,
- count: 3,
- effect: const WormEffect(
- spacing: 16,
- dotColor: Colors.black26,
- activeDotColor: Colors.redAccent,
- ),
- ),
- ),
- TextButton(
- onPressed: (){
- controller.nextPage(
- duration: const Duration(milliseconds: 500),
- curve: Curves.easeInOut
- );
- },
- child: const Text("NEXT"),
- )
- ],
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment