Skip to content

Commit

Permalink
Merge pull request #6 from rusiruavb/master
Browse files Browse the repository at this point in the history
Implement credit card form
  • Loading branch information
kalanarathnayake authored Oct 11, 2021
2 parents d5b5224 + c6cdf97 commit d51ec78
Show file tree
Hide file tree
Showing 51 changed files with 4,631 additions and 440 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.dialog_doc990_mobile"
minSdkVersion 16
minSdkVersion 18
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
Binary file added assets/images/appointment_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions lib/api_endpoints.dart
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
const RootURLPath = 'http://10.0.2.2:4000';
const GET_SEARCHED_DOCTORS = '$RootURLPath/doctor/search';
const CREATE_USER_ACCOUNT = '$RootURLPath/user/create';
const LOGIN_USER_ACCOUNT = '$RootURLPath/user/login';
const GET_USER_PROFILE = '$RootURLPath/user/';
const CREATE_APPOINTMENT = '$RootURLPath/appointment/create';
const GET_APPOINTMENTS = '$RootURLPath/appointment/';
const CREATE_REFUND_REQUEST = '$RootURLPath/refund/create';
const GET_REFUND_REQUESTS = '$RootURLPath/refund/';
157 changes: 157 additions & 0 deletions lib/components/common/rounded_gender_dropdown.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import 'package:dialog_doc990_mobile/constants.dart';
import 'package:flutter/material.dart';

class GenderDropdown extends StatefulWidget {
final ValueChanged<String> onChange;
final String text;
final bool isRequiredFeild;
final String value;

const GenderDropdown({
Key key,
this.isRequiredFeild,
this.onChange,
this.text,
this.value,
}) : super(key: key);

@override
_GenderDropdownState createState() => _GenderDropdownState(
isRequiredFeild: isRequiredFeild,
onChange: onChange,
text: text,
value: value,
);
}

class _GenderDropdownState extends State<GenderDropdown> {
final ValueChanged<String> onChange;
final String text;
final bool isRequiredFeild;
final String value;
bool _isFieldValid;

_GenderDropdownState({
Key key,
this.isRequiredFeild,
this.onChange,
this.text,
this.value,
});

@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
return Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
text,
style: TextStyle(
fontFamily: FONT_FAMILY_PRIMARY,
fontSize: 15,
),
textAlign: TextAlign.left,
),
SizedBox(
height: size.height * 0.005,
),
DropDownContainer(
child: DropdownButtonFormField<String>(
validator: (value) {
if (value == null) {
value = '';
}
if (value.isEmpty) {
setState(() {
_isFieldValid = false;
});
return null;
} else {
setState(() {
_isFieldValid = true;
});
return null;
}
},
items: gender
.map(
(item) => DropdownMenuItem(
child: Text(
item,
style: TextStyle(
fontFamily: FONT_FAMILY_PRIMARY,
fontSize: 18,
),
),
value: item,
),
)
.toList(),
hint: Text(
'Select your gender',
style: TextStyle(
fontFamily: FONT_FAMILY_PRIMARY,
fontSize: 18,
fontWeight: FontWeight.w500,
color: Colors.grey[600],
),
),
decoration: InputDecoration(
border: InputBorder.none,
),
onChanged: onChange,
)),
isRequiredFeild != null &&
isRequiredFeild &&
_isFieldValid != null &&
!_isFieldValid
? Padding(
padding: EdgeInsets.only(left: 5),
child: Text(
text + ' is required!',
style: TextStyle(
color: Colors.red[800],
fontFamily: FONT_FAMILY_PRIMARY,
fontSize: 14,
),
),
)
: Text(''),
SizedBox(
height: size.height * 0.010,
),
],
),
);
}
}

class DropDownContainer extends StatelessWidget {
final Widget child;

const DropDownContainer({
Key key,
this.child,
});

@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;

return Container(
padding: EdgeInsets.symmetric(horizontal: 18, vertical: 3),
width: size.width * 0.9,
height: 50,
decoration: BoxDecoration(
color: Colors.grey[300], borderRadius: BorderRadius.circular(8)),
child: child,
);
}
}

List<String> gender = [
'🧔 Male',
'👩 Female',
];
7 changes: 4 additions & 3 deletions lib/components/common/rounded_input_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ class _RoundedTextFeildState extends State<RoundedTextFeild> {
},
obscureText: isPassword ? _isObscure : false,
maxLength: isPhoneNumber ? 10 : 200,
keyboardType:
isNumber ? TextInputType.number : TextInputType.text,
style: TextStyle(fontFamily: FONT_FAMILY_PRIMARY, fontSize: 20),
keyboardType: isNumber && isPhoneNumber
? TextInputType.phone
: TextInputType.text,
style: TextStyle(fontFamily: FONT_FAMILY_PRIMARY, fontSize: 18),
onChanged: onChange,
decoration: InputDecoration(
border: InputBorder.none,
Expand Down
137 changes: 137 additions & 0 deletions lib/components/payment_input_fields/card_expire_field.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import 'package:dialog_doc990_mobile/constants.dart';
import 'package:flutter/material.dart';
import 'package:flutter_multi_formatter/flutter_multi_formatter.dart';

class CardExpireDateField extends StatefulWidget {
final ValueChanged<String> onChange;
final String text;
final IconData icon;
final String value;
final bool isRequiredFeild;
const CardExpireDateField({
Key key,
this.onChange,
this.icon,
this.value,
this.text,
this.isRequiredFeild,
}) : super(key: key);
@override
_CardExpireDateFieldState createState() => _CardExpireDateFieldState(
icon: icon,
onChange: onChange,
text: text,
value: value,
isRequiredFeild: isRequiredFeild,
);
}

class _CardExpireDateFieldState extends State<CardExpireDateField> {
final ValueChanged<String> onChange;
final String text;
final bool isNumber;
final String value;
final IconData icon;
final bool isRequiredFeild;
bool _isFieldValid;
bool _isObscure = true;
_CardExpireDateFieldState({
Key key,
this.onChange,
this.isNumber,
this.icon,
this.value,
this.text,
this.isRequiredFeild,
});
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
return Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
text,
style: TextStyle(
fontFamily: FONT_FAMILY_PRIMARY,
fontSize: 15,
fontWeight: FontWeight.w600,
),
textAlign: TextAlign.left,
),
SizedBox(
height: size.height * 0.005,
),
TextFieldContainer(
child: TextFormField(
validator: (value) {
if (value.isEmpty) {
setState(() {
_isFieldValid = false;
});
return null;
} else {
setState(() {
_isFieldValid = true;
});
return null;
}
},
keyboardType: TextInputType.number,
decoration: InputDecoration(
border: InputBorder.none,
hintText: value,
),
onChanged: onChange,
style: TextStyle(
fontFamily: FONT_FAMILY_PRIMARY,
fontSize: 18,
fontWeight: FontWeight.w500,
color: Colors.grey[800],
),
inputFormatters: [CreditCardExpirationDateFormatter()],
),
),
isRequiredFeild != null &&
isRequiredFeild &&
_isFieldValid != null &&
!_isFieldValid
? Padding(
padding: EdgeInsets.only(left: 5),
child: Text(
text + ' is required.',
style: TextStyle(
color: Colors.red[800],
fontFamily: FONT_FAMILY_PRIMARY,
fontSize: 12,
),
),
)
: Text(''),
SizedBox(
height: size.height * 0.010,
),
],
),
);
}
}

class TextFieldContainer extends StatelessWidget {
final Widget child;
const TextFieldContainer({Key key, this.child}) : super(key: key);

@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Container(
padding: EdgeInsets.symmetric(horizontal: 18, vertical: 1.5),
width: size.width * 0.9,
height: 50,
decoration: BoxDecoration(
color: Colors.grey[300], borderRadius: BorderRadius.circular(8)),
child: child,
);
}
}
Loading

0 comments on commit d51ec78

Please sign in to comment.