You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
diplomatic-quarter/lib/pages/landing/widgets/slider_view.dart

159 lines
6.0 KiB
Dart

import 'dart:math';
3 years ago
import 'package:auto_size_text/auto_size_text.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
3 years ago
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:flutter/material.dart';
3 years ago
import 'package:provider/provider.dart';
3 years ago
class SliderView extends StatelessWidget {
3 years ago
Function onLoginClick;
SliderView({this.onLoginClick});
ProjectViewModel projectViewModel;
3 years ago
@override
Widget build(BuildContext context) {
3 years ago
projectViewModel = Provider.of(context);
3 years ago
return Container(
decoration: cardRadius(20),
margin: EdgeInsets.all(0),
3 years ago
child: Container(
decoration: cardRadius(20,color: Color(0xFFF2B353E)),
3 years ago
clipBehavior: Clip.antiAlias,
margin: EdgeInsets.zero,
3 years ago
3 years ago
// padding: EdgeInsets.zero,
child: Container(
width: double.infinity,
height: double.infinity,
clipBehavior: Clip.antiAlias,
margin: EdgeInsets.zero,
decoration: projectViewModel.isArabic
? containerBottomRightRadiusWithGradientForAr(MediaQuery.of(context).size.width / 4)
: containerBottomRightRadiusWithGradient(MediaQuery.of(context).size.width / 4),
3 years ago
child: Card(
color: Colors.transparent,
margin: EdgeInsets.zero,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
mFlex(3),
Container(
3 years ago
decoration: projectViewModel.isArabic ? containerColorRadiusLeft(Color(0xFFFBF2E31), 100) : containerColorRadiusRight(Color(0xFFFBF2E31), 100),
padding: EdgeInsets.only(left: projectViewModel.isArabic ? 16 : 20, right: projectViewModel.isArabic ? 20 : 16, top: 6, bottom: 6),
3 years ago
child: Text(
3 years ago
TranslationBase.of(context).medicalFile,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 10,
letterSpacing: -0.3,
height: 1.2,
),
3 years ago
),
),
mFlex(2),
Padding(
padding: const EdgeInsets.only(left: 20, right: 20),
3 years ago
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
3 years ago
TranslationBase.of(context).cantSeeProfile,
3 years ago
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 17,
letterSpacing: -0.25,
height: 25 / 17,
3 years ago
),
),
Text(
3 years ago
TranslationBase.of(context).loginRegisterNow,
style: TextStyle(
color: Colors.white,
fontSize: 12,
letterSpacing: -0.36,
height: 1,
),
3 years ago
),
],
),
),
mFlex(2),
Padding(
padding: const EdgeInsets.only(left: 20, right: 20),
3 years ago
child: Container(
height: MediaQuery.of(context).size.width / 14,
width: MediaQuery.of(context).size.width / (projectViewModel.isArabic ? 4 : 6),
3 years ago
child: RaisedButton(
3 years ago
shape: cardRadiusNew(8),
3 years ago
color: Color(0xFFFBF2E31),
3 years ago
elevation: 0,
3 years ago
padding: EdgeInsets.zero,
3 years ago
onPressed: () {
onLoginClick();
},
child: Center(
child: AutoSizeText(
TranslationBase.of(context).login,
maxLines: 1,
style: TextStyle(
color: Colors.white,
fontSize: 13,
letterSpacing: -0.39,
height: 1,
3 years ago
),
3 years ago
),
),
),
),
),
mFlex(3),
],
),
),
),
),
);
}
}
class CurvedBottomClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
// I've taken approximate height of curved part of view
// Change it if you have exact spec for it
final roundingHeight = size.height * 3 / 5;
// this is top part of path, rectangle without any rounding
final filledRectangle = Rect.fromLTRB(0, 0, size.width, size.height - roundingHeight);
// this is rectangle that will be used to draw arc
// arc is drawn from center of this rectangle, so it's height has to be twice roundingHeight
// also I made it to go 5 units out of screen on left and right, so curve will have some incline there
final roundingRectangle = Rect.fromLTRB(-size.width, size.height - roundingHeight * 2, size.width, size.height);
final path = Path();
path.addRect(filledRectangle);
// so as I wrote before: arc is drawn from center of roundingRectangle
// 2nd and 3rd arguments are angles from center to arc start and end points
// 4th argument is set to true to move path to rectangle center, so we don't have to move it manually
path.arcTo(roundingRectangle, pi, -pi, true);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) {
// returning fixed 'true' value here for simplicity, it's not the part of actual question, please read docs if you want to dig into it
// basically that means that clipping will be redrawn on any changes
return true;
}
}