first
This commit is contained in:
13
lib/controller/auth/login_controller.dart
Normal file
13
lib/controller/auth/login_controller.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class LoginController extends GetxController {
|
||||
TextEditingController emailController = TextEditingController();
|
||||
TextEditingController phoneController = TextEditingController();
|
||||
TextEditingController firstNameController = TextEditingController();
|
||||
TextEditingController lastNameController = TextEditingController();
|
||||
|
||||
void login() {
|
||||
//TODO: Implement login logic
|
||||
}
|
||||
}
|
||||
89
lib/controller/functions/crud.dart
Normal file
89
lib/controller/functions/crud.dart
Normal file
@@ -0,0 +1,89 @@
|
||||
import 'dart:convert';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../constant/credential.dart';
|
||||
|
||||
class CRUD {
|
||||
Future<dynamic> get({
|
||||
required String link,
|
||||
Map<String, dynamic>? payload,
|
||||
}) async {
|
||||
var url = Uri.parse(link);
|
||||
var response = await http.get(
|
||||
url,
|
||||
headers: {
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AppCredintials.basicAuthCredentials))}',
|
||||
},
|
||||
);
|
||||
List data = jsonDecode(response.body)['data'];
|
||||
print(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
Future<dynamic> post({
|
||||
required String link,
|
||||
Map<String, dynamic>? payload,
|
||||
}) async {
|
||||
var url = Uri.parse(
|
||||
link,
|
||||
);
|
||||
var response = await http.post(
|
||||
url,
|
||||
body: payload,
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AppCredintials.basicAuthCredentials))}',
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
if (jsonData['status'] == 'success') {
|
||||
Get.snackbar(
|
||||
jsonData['status'],
|
||||
jsonData['message'],
|
||||
);
|
||||
|
||||
return response.body;
|
||||
} else if (jsonData['status'] == 'success1') {
|
||||
print(jsonData['data']);
|
||||
return jsonData['data'];
|
||||
}
|
||||
}
|
||||
return (response.body);
|
||||
}
|
||||
|
||||
Future<dynamic> update({
|
||||
required String endpoint,
|
||||
required Map<String, dynamic> data,
|
||||
required String id,
|
||||
}) async {
|
||||
var url = Uri.parse('$endpoint/$id');
|
||||
var response = await http.put(
|
||||
url,
|
||||
body: json.encode(data),
|
||||
headers: {
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AppCredintials.basicAuthCredentials))}',
|
||||
},
|
||||
);
|
||||
return json.decode(response.body);
|
||||
}
|
||||
|
||||
Future<dynamic> delete({
|
||||
required String endpoint,
|
||||
required String id,
|
||||
}) async {
|
||||
var url = Uri.parse('$endpoint/$id');
|
||||
var response = await http.delete(
|
||||
url,
|
||||
headers: {
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AppCredintials.basicAuthCredentials))}',
|
||||
},
|
||||
);
|
||||
return json.decode(response.body);
|
||||
}
|
||||
}
|
||||
9
lib/controller/functions/launch.dart
Normal file
9
lib/controller/functions/launch.dart
Normal file
@@ -0,0 +1,9 @@
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
void launchUrl1(String url) async {
|
||||
if (await canLaunchUrl(Uri.parse(url))) {
|
||||
launchUrl(Uri.parse(url));
|
||||
} else {
|
||||
print('Could not launch $url');
|
||||
}
|
||||
}
|
||||
36
lib/controller/local/local_controller.dart
Normal file
36
lib/controller/local/local_controller.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../main.dart';
|
||||
import '../themes/themes.dart';
|
||||
|
||||
class LocaleController extends GetxController {
|
||||
Locale? language;
|
||||
|
||||
ThemeData appTheme = themeEnglish;
|
||||
|
||||
changeLang(String langcode) {
|
||||
Locale locale = Locale(langcode);
|
||||
box.write(BoxName.lang, langcode);
|
||||
appTheme = langcode == "ar" ? themeArabic : themeEnglish;
|
||||
Get.changeTheme(appTheme);
|
||||
Get.updateLocale(locale);
|
||||
update();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
if (box.read(BoxName.lang) == "ar") {
|
||||
language = const Locale("ar");
|
||||
appTheme = themeArabic;
|
||||
} else if (box.read(BoxName.lang) == "en") {
|
||||
language = const Locale("en");
|
||||
appTheme = themeEnglish;
|
||||
} else {
|
||||
language = Locale(Get.deviceLocale!.languageCode);
|
||||
appTheme = themeEnglish;
|
||||
}
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
16
lib/controller/local/translations.dart
Normal file
16
lib/controller/local/translations.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class MyTranslation extends Translations {
|
||||
@override
|
||||
Map<String, Map<String, String>> get keys => {
|
||||
"ar": {
|
||||
"Choose Language": "اختر اللغة",
|
||||
},
|
||||
"en": {
|
||||
"Choose Language": "Choose Language",
|
||||
},
|
||||
"tr": {
|
||||
"Choose Language": "Dil seç",
|
||||
},
|
||||
};
|
||||
}
|
||||
49
lib/controller/themes/themes.dart
Normal file
49
lib/controller/themes/themes.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../constant/colors.dart';
|
||||
|
||||
ThemeData themeEnglish = ThemeData(
|
||||
fontFamily: "PlayfairDisplay",
|
||||
textTheme: const TextTheme(
|
||||
displaySmall: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 24,
|
||||
color: AppColor.primaryColor),
|
||||
displayLarge: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 22,
|
||||
color: AppColor.primaryColor),
|
||||
displayMedium: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 26,
|
||||
color: AppColor.primaryColor),
|
||||
bodyLarge: TextStyle(
|
||||
height: 2,
|
||||
color: AppColor.accentColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14),
|
||||
bodyMedium:
|
||||
TextStyle(height: 2, color: AppColor.accentColor, fontSize: 14)),
|
||||
primarySwatch: Colors.blue,
|
||||
);
|
||||
|
||||
ThemeData themeArabic = ThemeData(
|
||||
fontFamily: "Cairo",
|
||||
textTheme: const TextTheme(
|
||||
displayLarge: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 22,
|
||||
color: AppColor.primaryColor),
|
||||
displayMedium: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 26,
|
||||
color: AppColor.primaryColor),
|
||||
bodyLarge: TextStyle(
|
||||
height: 2,
|
||||
color: AppColor.accentColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14),
|
||||
bodyMedium:
|
||||
TextStyle(height: 2, color: AppColor.accentColor, fontSize: 14)),
|
||||
primarySwatch: Colors.blue,
|
||||
);
|
||||
Reference in New Issue
Block a user