BusinessAppFlutter/openclosenew/lib/iintroduction_screen.dart

129 lines
3.9 KiB
Dart
Raw Permalink Normal View History

import 'package:flutter/material.dart';
2022-05-31 13:48:18 +00:00
import 'package:openclosenew/colors.dart';
import 'package:openclosenew/home_screen.dart';
import 'FontFamily.dart';
class PageViewModel {
String title;
String body;
String image;
PageViewModel({required this.title, required this.body, required this.image});
}
class IntroScreen extends StatefulWidget {
@override
State<IntroScreen> createState() => _IntroScreenState();
}
class _IntroScreenState extends State<IntroScreen> {
int pageIndex = 0;
PageController pageController = PageController();
final List<PageViewModel> pages = [
PageViewModel(
title: '',
body: 'Best Hotels and Restaurants around you...',
image: 'assets/images/onboarding_image_1.png',
),
PageViewModel(
title: '',
body: 'Best Medicals, Clinics and Hospitals around you...',
image: 'assets/images/onboarding_image_2.png',
),
PageViewModel(
title: '',
body: 'Best Grocery and all Other Shops around you...',
image: "assets/images/onboarding_image_3.png",
)
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Expanded(
child: PageView.builder(
itemCount: pages.length,
controller: pageController,
physics: BouncingScrollPhysics(),
onPageChanged: (val) {
setState(() {
pageIndex = val;
});
},
itemBuilder: (context, pos) {
PageViewModel item = pages[pos];
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(item.image),
SizedBox(
height: 16,
),
Text(item.body)
],
),
);
},
),
),
Padding(
padding: const EdgeInsets.only(bottom: 16, left: 70, right: 16),
child: Row(
children: [
Spacer(),
Row(
children: [
for (int i = 0; i < pages.length; i++)
Container(
height: 8,
width: (pageIndex == i) ? 20 : 8,
margin: EdgeInsets.only(right: 8),
decoration: BoxDecoration(
color: (pageIndex == i)
2022-05-31 13:48:18 +00:00
? primaryColor
: Colors.green.shade100,
borderRadius: BorderRadius.circular(8)),
),
],
),
Spacer(),
(pageIndex == 2)
? FloatingActionButton(
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (_) => Register()));
},
elevation: 0,
2022-05-31 13:48:18 +00:00
backgroundColor: primaryColor,
child: Icon(
Icons.arrow_forward_rounded,
2022-05-31 13:48:18 +00:00
color: White,
),
)
: TextButton(
onPressed: () {
pageController.jumpToPage(2);
},
child: Text(
"Skip",
style: TextStyle(
color: Gray,
fontSize: 18,
fontFamily: Font,
),
),
),
],
),
),
],
),
);
}
}