Files
fcs/lib/pages/main/welcome_page.dart

156 lines
5.5 KiB
Dart
Raw Normal View History

2020-10-07 02:33:06 +06:30
import 'package:fcs/localization/transalation.dart';
import 'package:fcs/pages/main/model/language_model.dart';
import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/widgets/bottom_widgets.dart';
2020-06-29 21:19:54 +06:30
import 'package:flutter/cupertino.dart';
2020-06-24 16:06:40 +06:30
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import 'package:provider/provider.dart';
2020-10-07 02:33:06 +06:30
import '../../helpers/theme.dart';
import '../signin/signin_page.dart';
import '../widgets/banner.dart';
import '../widgets/offline_redirect.dart';
2020-06-24 16:06:40 +06:30
final msgLog = Logger('backgroundMessageHandler');
2020-08-30 21:26:37 +06:30
class WelcomePage extends StatefulWidget {
2020-06-24 16:06:40 +06:30
@override
2020-08-30 21:26:37 +06:30
_WelcomePageState createState() => _WelcomePageState();
2020-06-24 16:06:40 +06:30
}
typedef BtnCallback();
2020-08-30 21:26:37 +06:30
class _WelcomePageState extends State<WelcomePage> {
2020-06-24 16:06:40 +06:30
final log = Logger('_HomePageWelcomeState');
2020-09-12 03:34:52 +06:30
2021-09-10 12:00:08 +06:30
late String pin;
2020-09-12 03:34:52 +06:30
List<bool> isSelected = [true, false];
2020-06-24 16:06:40 +06:30
@override
void initState() {
super.initState();
2020-09-12 03:34:52 +06:30
_loadLang();
}
void _loadLang() {
isSelected =
Provider.of<LanguageModel>(context, listen: false).currentState;
2020-06-24 16:06:40 +06:30
}
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return OfflineRedirect(
child: FlavorBanner(
child: Scaffold(
2020-09-12 03:34:52 +06:30
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment
.bottomCenter, // 10% of the width, so there are ten blinds.
colors: [
Color(0xd0272262),
Color(0xfa272262),
], // whitish to gray
)),
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
2020-06-24 16:06:40 +06:30
ToggleButtons(
children: <Widget>[
Image.asset(
'icons/flags/png/us.png',
package: 'country_icons',
fit: BoxFit.fitWidth,
width: 25,
),
Image.asset(
'icons/flags/png/mm.png',
package: 'country_icons',
fit: BoxFit.fitWidth,
width: 25,
)
],
2020-09-12 03:34:52 +06:30
selectedBorderColor: Colors.white12,
borderColor: Colors.transparent,
2020-06-24 16:06:40 +06:30
onPressed: _langChange,
isSelected: isSelected,
),
2024-01-09 13:11:22 +06:30
TextButton(
2020-06-24 16:06:40 +06:30
onPressed: () {
2020-10-14 13:54:42 +06:30
Navigator.of(context).push(CupertinoPageRoute(
builder: (context) => SigninPage()));
2020-06-24 16:06:40 +06:30
},
child: Text(
2020-09-12 03:34:52 +06:30
getLocalString(context, "welcome.signin"),
2020-06-24 16:06:40 +06:30
style: siginButtonStyle,
),
),
2020-09-12 03:34:52 +06:30
],
),
2020-09-04 15:30:10 +06:30
Expanded(
2020-09-12 03:34:52 +06:30
child: Column(
2020-09-04 15:30:10 +06:30
children: <Widget>[
2020-09-12 03:34:52 +06:30
Expanded(
child: Center(
child: Text(
getLocalString(context, "welcome.msg"),
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontFamily: "Roboto"),
),
2020-09-04 15:30:10 +06:30
),
2020-06-29 21:19:54 +06:30
),
2020-09-12 03:34:52 +06:30
Container(
padding: EdgeInsets.only(top: 0),
child: CircleAvatar(
radius: (25),
backgroundColor: Colors.white,
child: ClipRRect(
borderRadius: BorderRadius.circular(50),
child: Image.asset("assets/logo.jpg"),
)),
),
2020-09-04 15:30:10 +06:30
Padding(
2020-09-12 03:34:52 +06:30
padding:
const EdgeInsets.only(bottom: 10.0, top: 5),
2020-09-04 15:30:10 +06:30
child: Text(
2020-09-12 03:34:52 +06:30
"by FCS Logistics",
2020-09-04 15:30:10 +06:30
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
2020-09-12 03:34:52 +06:30
fontSize: 11,
2020-09-04 15:30:10 +06:30
fontFamily: "Roboto"),
),
2020-08-30 21:26:37 +06:30
),
],
),
2020-09-04 15:30:10 +06:30
),
BottomWidgets(),
2020-06-24 16:06:40 +06:30
],
))),
),
);
}
_langChange(index) {
2020-09-06 02:36:57 +06:30
var languageModel = Provider.of<LanguageModel>(context, listen: false);
2020-06-24 16:06:40 +06:30
languageModel.saveLanguage(Translation().supportedLanguages[index]);
setState(() {
isSelected.asMap().forEach((i, e) {
isSelected[i] = false;
});
isSelected[index] = !isSelected[index];
});
}
}