2020-10-28 13:10:43 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import '../home/home.dart';
|
|
|
|
import '../state/setting_state.dart';
|
|
|
|
import '../util/extension_helper.dart';
|
|
|
|
import '../util/pageroute.dart';
|
|
|
|
import 'firstpage.dart';
|
|
|
|
import 'fourthpage.dart';
|
|
|
|
import 'secondpage.dart';
|
|
|
|
import 'thirdpage.dart';
|
|
|
|
|
|
|
|
enum Goto { home, settings }
|
|
|
|
|
|
|
|
class SlideIntro extends StatefulWidget {
|
|
|
|
final Goto goto;
|
|
|
|
SlideIntro({this.goto, Key key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_SlideIntroState createState() => _SlideIntroState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SlideIntroState extends State<SlideIntro> {
|
2021-01-01 07:51:23 +01:00
|
|
|
//final List<BoxShadow> _customShadow = [
|
|
|
|
// BoxShadow(blurRadius: 2, offset: Offset(-2, -2), color: Colors.white54),
|
|
|
|
// BoxShadow(
|
|
|
|
// blurRadius: 8,
|
|
|
|
// offset: Offset(2, 2),
|
|
|
|
// color: Colors.grey[600].withOpacity(0.4))
|
|
|
|
//];
|
2020-10-28 13:10:43 +01:00
|
|
|
PageController _controller;
|
|
|
|
double _position;
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_position = 0;
|
|
|
|
_controller = PageController()
|
|
|
|
..addListener(() {
|
|
|
|
setState(() {
|
|
|
|
_position = _controller.page;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_controller.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
2021-01-01 07:51:23 +01:00
|
|
|
Widget _indicatorWidget(int index) {
|
|
|
|
final distance = (_position - index).abs();
|
|
|
|
final size = distance > 1 ? 10.0 : 10 * (2 - distance);
|
|
|
|
return Center(
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: distance < 0.2
|
|
|
|
? Text(
|
|
|
|
(index + 1).toString(),
|
|
|
|
style: TextStyle(color: Color.fromRGBO(35, 204, 198, 1)),
|
|
|
|
)
|
|
|
|
: Center(),
|
|
|
|
height: size,
|
|
|
|
width: size,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-10-28 13:10:43 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
|
|
|
value: SystemUiOverlayStyle(
|
|
|
|
statusBarBrightness: Brightness.light,
|
|
|
|
systemNavigationBarIconBrightness: Brightness.dark),
|
|
|
|
child: Scaffold(
|
|
|
|
backgroundColor: Colors.grey[100],
|
|
|
|
body: Container(
|
|
|
|
child: Stack(
|
|
|
|
children: <Widget>[
|
|
|
|
PageView(
|
|
|
|
physics: const PageScrollPhysics(),
|
|
|
|
controller: _controller,
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
children: <Widget>[
|
|
|
|
FirstPage(),
|
|
|
|
SecondPage(),
|
|
|
|
ThirdPage(),
|
|
|
|
FourthPage(),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
bottom: 0,
|
|
|
|
left: 0,
|
|
|
|
child: Container(
|
|
|
|
color: Colors.grey[100].withOpacity(0.5),
|
2021-01-01 07:51:23 +01:00
|
|
|
width: context.width,
|
2020-10-28 13:10:43 +01:00
|
|
|
padding:
|
|
|
|
EdgeInsets.only(left: 40, right: 20, bottom: 30, top: 20),
|
|
|
|
child: Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
2021-01-01 07:51:23 +01:00
|
|
|
SizedBox(
|
|
|
|
width: context.width / 3,
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
children: <Widget>[
|
|
|
|
_indicatorWidget(0),
|
|
|
|
_indicatorWidget(1),
|
|
|
|
_indicatorWidget(2),
|
|
|
|
_indicatorWidget(3)
|
|
|
|
],
|
2020-10-28 13:10:43 +01:00
|
|
|
),
|
|
|
|
),
|
2021-01-01 07:51:23 +01:00
|
|
|
Spacer(),
|
2020-10-28 13:10:43 +01:00
|
|
|
Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
height: 40,
|
|
|
|
width: 80,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border.all(width: 1, color: Colors.white),
|
2021-01-01 07:51:23 +01:00
|
|
|
borderRadius: BorderRadius.circular(20),
|
2020-10-28 13:10:43 +01:00
|
|
|
color: Colors.white,
|
2021-01-01 07:51:23 +01:00
|
|
|
//boxShadow: _customShadow,
|
2020-10-28 13:10:43 +01:00
|
|
|
),
|
|
|
|
child: Material(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: _position < 2.5
|
|
|
|
? InkWell(
|
|
|
|
borderRadius:
|
|
|
|
BorderRadius.all(Radius.circular(20)),
|
|
|
|
onTap: () => _controller.animateToPage(
|
|
|
|
_position.toInt() + 1,
|
|
|
|
duration: Duration(milliseconds: 200),
|
|
|
|
curve: Curves.linear),
|
|
|
|
child: SizedBox(
|
|
|
|
height: 40,
|
|
|
|
width: 80,
|
|
|
|
child: Center(
|
|
|
|
child: Text(context.s.next,
|
|
|
|
style: TextStyle(
|
2021-01-01 07:51:23 +01:00
|
|
|
color: Colors.black,
|
|
|
|
fontWeight:
|
|
|
|
FontWeight.bold)))))
|
2020-10-28 13:10:43 +01:00
|
|
|
: InkWell(
|
2021-01-01 07:51:23 +01:00
|
|
|
borderRadius: BorderRadius.circular(20),
|
2020-10-28 13:10:43 +01:00
|
|
|
onTap: () {
|
|
|
|
if (widget.goto == Goto.home) {
|
|
|
|
Navigator.push(context,
|
|
|
|
SlideLeftRoute(page: Home()));
|
|
|
|
Provider.of<SettingState>(context,
|
|
|
|
listen: false)
|
|
|
|
.saveShowIntro(1);
|
|
|
|
} else if (widget.goto == Goto.settings) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: SizedBox(
|
|
|
|
height: 40,
|
|
|
|
width: 80,
|
|
|
|
child: Center(
|
|
|
|
child: Text(context.s.done,
|
|
|
|
style: TextStyle(
|
2021-01-01 07:51:23 +01:00
|
|
|
color: Colors.black,
|
|
|
|
fontWeight:
|
|
|
|
FontWeight.bold))))),
|
2020-10-28 13:10:43 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|