Skip to content

Commit

Permalink
add some commons widget, signup demo ui
Browse files Browse the repository at this point in the history
  • Loading branch information
khoabm committed Oct 6, 2023
1 parent 9030840 commit 83b6aa5
Show file tree
Hide file tree
Showing 14 changed files with 612 additions and 112 deletions.
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<!-- Include only if your app benefits from precise location access. -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application
android:label="goshare"
android:name="${applicationName}"
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.9.10'
repositories {
google()
mavenCentral()
Expand Down
10 changes: 6 additions & 4 deletions lib/common/large_button.dart → lib/common/app_button.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import 'package:flutter/material.dart';
import 'package:goshare/theme/pallet.dart';

class LargeButton extends StatelessWidget {
class AppButton extends StatelessWidget {
final String buttonText;
final double? fontSize;
final VoidCallback onPressed;
const LargeButton({
const AppButton({
super.key,
required this.buttonText,
required this.onPressed,
this.fontSize,
});

@override
Expand All @@ -24,9 +26,9 @@ class LargeButton extends StatelessWidget {
),
child: Text(
buttonText,
style: const TextStyle(
style: TextStyle(
color: Colors.white,
fontSize: 22,
fontSize: fontSize ?? 22,
fontWeight: FontWeight.bold,
),
),
Expand Down
75 changes: 75 additions & 0 deletions lib/common/app_text_field.dart
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;
},
);
}
}
40 changes: 40 additions & 0 deletions lib/common/home_center_container.dart
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,
);
}
}
2 changes: 2 additions & 0 deletions lib/core/constants/constants.dart
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';
}
44 changes: 44 additions & 0 deletions lib/core/locations_util.dart
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;
}
}
17 changes: 17 additions & 0 deletions lib/features/home/repositories/home_repository.dart
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';
}
}
Loading

0 comments on commit 83b6aa5

Please sign in to comment.