-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add some commons widget, signup demo ui
- Loading branch information
Showing
14 changed files
with
612 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class AppTextField extends StatelessWidget { | ||
final TextEditingController controller; | ||
final String hintText; | ||
final bool isObscure; | ||
final int maxLines; | ||
final TextInputType inputType; | ||
final Icon? prefixIcons; | ||
final IconButton? suffixIcon; | ||
final Function(String)? onChanged; | ||
final String? label; | ||
final int? maxLength; | ||
const AppTextField({ | ||
Key? key, | ||
required this.controller, | ||
required this.hintText, | ||
this.isObscure = false, | ||
this.maxLines = 1, | ||
this.inputType = TextInputType.text, | ||
this.prefixIcons, | ||
this.suffixIcon, | ||
this.onChanged, | ||
this.label, | ||
this.maxLength, | ||
}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return TextFormField( | ||
obscureText: isObscure, | ||
maxLines: maxLines, | ||
controller: controller, | ||
keyboardType: inputType, | ||
decoration: InputDecoration( | ||
labelText: label, | ||
prefixIcon: prefixIcons, | ||
suffixIcon: suffixIcon, | ||
contentPadding: const EdgeInsets.only( | ||
left: 10.0, | ||
top: 15.0, | ||
bottom: 15.0, | ||
), | ||
hintText: hintText, | ||
border: const OutlineInputBorder( | ||
borderSide: BorderSide( | ||
color: Colors.black45, | ||
), | ||
), | ||
enabledBorder: const OutlineInputBorder( | ||
borderSide: BorderSide( | ||
color: Colors.black45, | ||
), | ||
), | ||
), | ||
onChanged: onChanged, | ||
maxLength: maxLength, | ||
validator: (val) { | ||
if (val == null || val.isEmpty) { | ||
return 'Cần ${hintText.toLowerCase()}'; | ||
} | ||
// log(); | ||
if (inputType.toString().contains('emailAddress')) { | ||
RegExp email = RegExp( | ||
r"^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$"); | ||
bool emailValid = email.hasMatch(val); | ||
if (!emailValid) { | ||
return 'Incorrect Email'; | ||
} | ||
} | ||
return null; | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class HomeCenterContainer extends StatelessWidget { | ||
final double? width; | ||
final double? height; | ||
final double? verticalPadding; | ||
final double? horizontalPadding; | ||
final Widget? child; | ||
const HomeCenterContainer({ | ||
super.key, | ||
this.width, | ||
this.height, | ||
this.verticalPadding, | ||
this.horizontalPadding, | ||
this.child, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
alignment: Alignment.center, | ||
padding: EdgeInsets.symmetric( | ||
vertical: verticalPadding ?? 12.0, | ||
horizontal: horizontalPadding ?? 12.0, | ||
), | ||
decoration: const BoxDecoration( | ||
color: Colors.white, | ||
borderRadius: BorderRadius.only( | ||
topLeft: Radius.circular(30), | ||
bottomLeft: Radius.circular(20), | ||
topRight: Radius.circular(30), | ||
bottomRight: Radius.circular(20), | ||
), | ||
), | ||
width: width, | ||
height: height, | ||
child: child, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
class Constants { | ||
static const carBanner = 'assets/images/car_banner.svg'; | ||
|
||
static const apiKey = 'AIzaSyC_9i-bGTTmVH8nvIWYiDNTyO7bIhAboKs'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:location/location.dart'; | ||
import 'dart:async'; | ||
|
||
final locationProvider = Provider<LocationUtils>((ref) => LocationUtils()); | ||
|
||
class LocationUtils { | ||
Future<LocationData?> getCurrentLocation() async { | ||
Location location = Location(); | ||
|
||
bool serviceEnabled; | ||
PermissionStatus permissionGranted; | ||
|
||
serviceEnabled = await location.serviceEnabled(); | ||
print(serviceEnabled.toString()); | ||
if (!serviceEnabled) { | ||
serviceEnabled = await location.requestService(); | ||
print('await for services enable'); | ||
if (!serviceEnabled) { | ||
print('service enable false'); | ||
return null; | ||
} | ||
} | ||
|
||
permissionGranted = await location.hasPermission(); | ||
if (permissionGranted == PermissionStatus.denied) { | ||
print('await for permission granted'); | ||
permissionGranted = await location.requestPermission(); | ||
if (permissionGranted != PermissionStatus.granted) { | ||
print('permission granted false'); | ||
return null; | ||
} | ||
} | ||
|
||
// Get location data if permission is granted | ||
if (permissionGranted == PermissionStatus.granted) { | ||
print('get current location'); | ||
LocationData locationData = await location.getLocation(); | ||
return locationData; | ||
} | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
|
||
final homeRepositoryProvider = Provider((ref) { | ||
return HomeRepository(); | ||
}); | ||
|
||
class HomeRepository { | ||
String greeting() { | ||
var hour = DateTime.now().hour; | ||
if (hour < 12) { | ||
return 'Buổi sáng tốt lành'; | ||
} else if (hour < 17) { | ||
return 'Buổi trưa vui vẻ'; | ||
} | ||
return 'Buổi tối tốt lành'; | ||
} | ||
} |
Oops, something went wrong.