commit frontend files

parent 0026ce9a
import 'dart:async';
import 'dart:convert';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:http/http.dart' as http;
import 'api_response.dart';
import 'api_status.dart';
// const baseUrl = "http://127.0.0.1:5000";
const baseUrl = "http://10.0.2.2:5000";
const timeout = 80;
class ApiCaller {
static Future<ApiResponse> postRequest(String endpoint,
{Map<String, dynamic>? data, Map<String, String>? headers}) async {
try {
var connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult == ConnectivityResult.mobile ||
connectivityResult == ConnectivityResult.wifi) {
Map<String, String> allHeaders = new Map();
allHeaders["Accept"] = "application/json";
if (headers != null && headers.length > 0) {
allHeaders.addAll(headers);
}
print("Url: " + baseUrl + endpoint);
// print(data);
final response = await http
.post(
Uri.parse(baseUrl + endpoint),
headers: allHeaders,
body: jsonEncode(data),
)
.timeout(const Duration(seconds: timeout));
print(response.statusCode.toString() + " Response: " + response.body);
return ApiResponse(response: response, validateToken: false);
} else {
ApiResponse response = ApiResponse(response: null);
response.isSuccess = false;
response.apiStatus = ApiStatus.NO_INTERNET;
response.statusMessage = "Internet connection not available";
return response;
}
} catch (e) {
ApiResponse response = ApiResponse();
if (e is TimeoutException) {
response.isSuccess = false;
response.apiStatus = ApiStatus.TIMEOUT;
response.statusMessage = e.toString();
} else {
response.isSuccess = false;
response.apiStatus = ApiStatus.EXCEPTION;
response.statusMessage = e.toString();
}
print(response.toString());
return response;
}
}
static Future<ApiResponse> putRequest(String endpoint,
{Map<String, dynamic>? data, Map<String, String>? headers}) async {
try {
var connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult == ConnectivityResult.mobile ||
connectivityResult == ConnectivityResult.wifi) {
Map<String, String> allHeaders = new Map();
allHeaders["Accept"] = "application/json";
if (headers != null && headers.length > 0) {
allHeaders.addAll(headers);
}
print("Url: " + baseUrl + endpoint);
// print(data);
final response = await http
.put(
Uri.parse(baseUrl + endpoint),
headers: allHeaders,
body: data,
)
.timeout(const Duration(seconds: timeout));
print(response.statusCode.toString() + " Response: " + response.body);
return ApiResponse(response: response, validateToken: false);
} else {
ApiResponse response = ApiResponse(response: null);
response.isSuccess = false;
response.apiStatus = ApiStatus.NO_INTERNET;
response.statusMessage = "Internet connection not available";
return response;
}
} catch (e) {
ApiResponse response = ApiResponse();
if (e is TimeoutException) {
response.isSuccess = false;
response.apiStatus = ApiStatus.TIMEOUT;
response.statusMessage = e.toString();
} else {
response.isSuccess = false;
response.apiStatus = ApiStatus.EXCEPTION;
response.statusMessage = e.toString();
}
print(response.toString());
return response;
}
}
static Future<ApiResponse> getRequest(String endpoint,
{Map<String, String>? headers}) async {
try {
var connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult == ConnectivityResult.mobile ||
connectivityResult == ConnectivityResult.wifi) {
Map<String, String> allHeaders = new Map();
if (headers != null && headers.length > 0) {
allHeaders.addAll(headers);
}
print("Url: " + baseUrl + endpoint);
final response = await http
.get(Uri.parse(baseUrl + endpoint), headers: headers)
.timeout(const Duration(seconds: timeout));
print(response.statusCode.toString() + " Response: " + response.body);
return ApiResponse(response: response, validateToken: false);
} else {
ApiResponse response = ApiResponse();
response.isSuccess = false;
response.apiStatus = ApiStatus.NO_INTERNET;
response.statusMessage = "Internet connection not available";
return response;
}
} catch (e) {
ApiResponse response = ApiResponse();
if (e is TimeoutException) {
response.isSuccess = false;
response.apiStatus = ApiStatus.TIMEOUT;
response.statusMessage = e.toString();
} else {
response.isSuccess = false;
response.apiStatus = ApiStatus.EXCEPTION;
response.statusMessage = e.toString();
}
return response;
}
}
static Future<ApiResponse> deleteRequest(String endpoint,
{Map<String, dynamic>? data, Map<String, String>? headers}) async {
try {
var connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult == ConnectivityResult.mobile ||
connectivityResult == ConnectivityResult.wifi) {
Map<String, String> allHeaders = new Map();
allHeaders["Accept"] = "application/json";
if (headers != null && headers.length > 0) {
allHeaders.addAll(headers);
}
print("Url: " + baseUrl + endpoint);
final response = await http
.delete(Uri.parse(baseUrl + endpoint), headers: headers)
.timeout(const Duration(seconds: timeout));
print("Response: " +
response.body +
" Code: " +
response.statusCode.toString());
return ApiResponse(response: response, validateToken: false);
} else {
ApiResponse response = ApiResponse();
response.isSuccess = false;
response.apiStatus = ApiStatus.NO_INTERNET;
response.statusMessage = "Internet connection not available";
return response;
}
} catch (e) {
ApiResponse response = ApiResponse();
if (e is TimeoutException) {
response.isSuccess = false;
response.apiStatus = ApiStatus.TIMEOUT;
response.statusMessage = e.toString();
} else {
response.isSuccess = false;
response.apiStatus = ApiStatus.EXCEPTION;
response.statusMessage = e.toString();
}
return response;
}
}
}
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import 'package:http_parser/http_parser.dart';
import 'api_caller.dart';
import 'api_response.dart';
class ApiCalls {
static Future<ApiResponse> predictMedicineFromSymptom(
{required List<dynamic> symptoms}) async {
try {
var data = <String, dynamic>{};
data['disease'] = symptoms;
Map<String, String> headers = new Map();
headers["Accept"] = "application/json";
headers["content-type"] = "application/json";
return ApiCaller.postRequest('/disease', data: data, headers: headers);
} catch (e) {
ApiResponse response = ApiResponse();
response.isSuccess = false;
response.statusMessage = e.toString();
return response;
}
}
static Future<ApiResponse> getStage({required List<dynamic> symptoms}) async {
try {
var data = <String, dynamic>{};
data['disease'] = symptoms;
Map<String, String> headers = new Map();
headers["Accept"] = "application/json";
headers["content-type"] = "application/json";
return ApiCaller.postRequest('/stage', data: data, headers: headers);
} catch (e) {
ApiResponse response = ApiResponse();
response.isSuccess = false;
response.statusMessage = e.toString();
return response;
}
}
static Future<ApiResponse> getMedicine(
{required String disease, required String stage}) async {
try {
var data = <String, dynamic>{};
data['prognosis'] = disease;
data['stage'] = stage;
Map<String, String> headers = new Map();
headers["Accept"] = "application/json";
headers["content-type"] = "application/json";
return ApiCaller.postRequest('/medi', data: data, headers: headers);
} catch (e) {
ApiResponse response = ApiResponse();
response.isSuccess = false;
response.statusMessage = e.toString();
return response;
}
}
static Future<ApiResponse> sendImage({required String image}) async {
try {
var data = <String, dynamic>{};
data['disease'] = image;
Map<String, String> headers = new Map();
headers["Accept"] = "application/json";
headers["content-type"] = "application/json";
return ApiCaller.postRequest('/decodejson', data: data, headers: headers);
} catch (e) {
ApiResponse response = ApiResponse();
response.isSuccess = false;
response.statusMessage = e.toString();
return response;
}
}
}
import 'dart:convert';
import 'package:http/http.dart';
import 'api_status.dart';
class ApiResponse {
Response? response;
ApiStatus apiStatus = ApiStatus.UNKNOWN;
bool isSuccess = false;
late String statusMessage;
dynamic jsonBody;
dynamic extra;
ApiResponse({this.response, bool validateToken = true}) {
if (validateToken) {
if (response != null &&
response!.statusCode != null &&
response!.statusCode == 401) {
isSuccess = false;
_setErrorMessage("Token expired");
apiStatus = ApiStatus.CLIENT_ERROR;
return;
}
}
if (response != null) {
_processResponse();
}
}
void _setApiStatus(ApiStatus status) {
apiStatus = status;
if (status == ApiStatus.SUCCESS) {
isSuccess = true;
} else {
isSuccess = false;
}
}
void _processResponse() {
try {
if (response != null) {
if (!(response!.statusCode == 200 ||
response!.statusCode == 201 ||
response!.statusCode == 202)) {
if (response!.statusCode >= 400 && response!.statusCode <= 499) {
_setApiStatus(ApiStatus.CLIENT_ERROR);
try {
jsonBody = json.decode(response!.body).cast<String, dynamic>();
} catch (e) {
print(e);
}
} else if (response!.statusCode >= 500 &&
response!.statusCode <= 599) {
_setApiStatus(ApiStatus.SERVICE_ERROR);
} else {
_setApiStatus(ApiStatus.UNKNOWN);
}
_setErrorMessage(response!.reasonPhrase.toString());
} else {
jsonBody = _getJsonBody();
// if (jsonBody != null) {
_setApiStatus(ApiStatus.SUCCESS);
// } else {
// _setApiStatus(ApiStatus.PARSE_ERROR);
// _setErrorMessage("Null json response");
// }
}
} else {
_setApiStatus(ApiStatus.PARSE_ERROR);
_setErrorMessage("Null response");
}
} catch (e) {
_setApiStatus(ApiStatus.EXCEPTION);
_setErrorMessage(e.toString());
}
}
dynamic _getJsonBody() {
try {
if (response!.body != null) {
print('JsonBody --- here');
return json.decode(response!.body);
} else {
_setApiStatus(ApiStatus.PARSE_ERROR);
_setErrorMessage("Null response body");
}
} catch (e) {
print(e);
_setApiStatus(ApiStatus.EXCEPTION);
_setErrorMessage("JSON Parse Error: " + e.toString());
}
}
void _setErrorMessage(String message) {
print(message);
this.statusMessage = message;
}
int getHttpStatusCode() {
try {
return response!.statusCode;
} catch (e) {
print(e);
return -1;
}
}
}
enum ApiStatus {
UNKNOWN,
SUCCESS,
NO_INTERNET,
TIMEOUT,
CLIENT_ERROR,
SERVICE_ERROR,
EXCEPTION,
PARSE_ERROR
}
import 'package:flutter/material.dart';
import 'package:medicare/views/onBoarding/loginScreen.dart';
import 'package:medicare/views/onBoarding/splashScreen.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Home();
}
}
class Home extends StatefulWidget {
const Home({Key? key}) : super(key: key);
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(fontFamily: 'Roboto'),
home: SplashScreen(),
);
}
}
import 'package:flutter/material.dart';
const DefaultColor = Color(0xFFFF9470);
const InactiveColor = Color(0xFFCFCFCF);
const Button2BorderColor = Color(0xFFC6C6C6);
const WarningAlertColor = Color(0xFFFFD429);
const SuccessAlertColor = Color(0xFFB5BF24);
const ErrorAlertColor = Color(0xFFA30000);
//Fonts and text
const String DefaultFont = 'Roboto';
const LogoText = TextStyle(
fontFamily: DefaultFont,
color: DefaultColor,
fontWeight: FontWeight.w900,
fontSize: 30.0);
const HeaderStyle = TextStyle(
fontFamily: DefaultFont,
color: DefaultColor,
fontSize: 24.0,
fontWeight: FontWeight.bold);
const HeaderStyle2 = TextStyle(
fontFamily: DefaultFont,
color: Colors.black45,
fontSize: 24.0,
fontWeight: FontWeight.bold);
const HeaderStyle3 = TextStyle(
fontFamily: DefaultFont,
color: DefaultColor,
fontSize: 26.0,
fontWeight: FontWeight.bold);
const SubHeadStyle =
TextStyle(color: DefaultColor, fontWeight: FontWeight.bold, fontSize: 16);
const LabelStyle1 = TextStyle(
fontFamily: DefaultFont,
color: Colors.black54,
fontWeight: FontWeight.w500,
fontSize: 18.0);
const HintStyle1 = TextStyle(
fontFamily: DefaultFont,
color: Color(0XFFABABAB),
fontWeight: FontWeight.w500,
fontSize: 15.0);
const SeeAllStyle = TextStyle(
fontFamily: DefaultFont,
color: Color(0xFF5F8DF3),
fontWeight: FontWeight.w600,
fontSize: 16.0);
const LogOut = TextStyle(
fontFamily: DefaultFont,
color: Colors.red,
fontWeight: FontWeight.w600,
fontSize: 16.0);
const ProfileDataStyle = TextStyle(
fontFamily: DefaultFont,
color: Colors.white,
fontWeight: FontWeight.w500,
fontSize: 15.0);
const TextButtonStyle = TextStyle(
fontFamily: DefaultFont,
color: Color(0xFFAFB0B1),
fontSize: 12.0,
);
const greyNormalTextStyle = TextStyle(
color: Colors.grey, fontSize: 18.0, height: 1.3, fontFamily: DefaultFont);
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:image_picker/image_picker.dart';
class Helper {
static Future<List<XFile>> selectImages() async {
final List<XFile>? _imageFileList = [];
final ImagePicker _picker = ImagePicker();
final List<XFile>? _selectedImages =
await _picker.pickMultiImage(imageQuality: 85);
if (_selectedImages!.isNotEmpty) {
_imageFileList!.addAll(_selectedImages);
if (_imageFileList.length > 1) {
int l = _imageFileList.length;
_imageFileList.removeRange(2, l);
// print("Sorry can't have more than 10");
}
}
print("Image list length : " + _imageFileList!.length.toString());
return _imageFileList;
}
static Future<List<XFile>> selectNewImages(int imageLimiter) async {
int pick = 1 - imageLimiter;
final List<XFile>? _imageFileList = [];
final ImagePicker _picker = ImagePicker();
final List<XFile>? _selectedImages = await _picker.pickMultiImage();
if (_selectedImages!.isNotEmpty) {
_imageFileList!.addAll(_selectedImages);
if (_imageFileList.length > pick) {
int l = _imageFileList.length;
_imageFileList.removeRange(pick, l);
Fluttertoast.showToast(
msg: "Can not have more than 1 image",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
);
}
}
print("Image list length : " + _imageFileList!.length.toString());
return _imageFileList;
}
}
void showSnackBar(String message, BuildContext context) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(message)));
}
import 'package:shared_preferences/shared_preferences.dart';
class Settings {
static setSigned(bool signed) async {
final SharedPreferences sharedPrefs = await SharedPreferences.getInstance();
sharedPrefs.setBool("signed", signed);
}
static Future<bool?> getSigned() async {
final SharedPreferences sharedPrefs = await SharedPreferences.getInstance();
return sharedPrefs.getBool("signed");
}
static setAccessToken(String token) async {
final SharedPreferences sharedPrefs = await SharedPreferences.getInstance();
sharedPrefs.setString("access_token", token);
}
static Future<String?> getAccessToken() async {
final SharedPreferences sharedPrefs = await SharedPreferences.getInstance();
return sharedPrefs.getString("access_token");
}
static setUserEmail(String email) async {
final SharedPreferences sharedPrefs = await SharedPreferences.getInstance();
sharedPrefs.setString("user_email", email);
}
static Future<String?> getUserEmail() async {
final SharedPreferences sharedPrefs = await SharedPreferences.getInstance();
return sharedPrefs.getString("user_email");
}
}
import 'package:shared_preferences/shared_preferences.dart';
List<dynamic> diseases = [
"Coccidiosis",
"Salmonella",
"Pcr Cocidiosis",
"Pcr Salmonella",
"NCD",
"Pcr NCD"
];
Map<String, bool> symptomsList = {
"Weight loss": false,
"Loss of appetite": false,
"Swollen joints": false,
"Lameness": false,
"Nasal discharge": false,
"Ocular discharge": false,
"Ruffled feathers": false,
"Diarrhea": false,
"Mites": false,
"Egg production decrease": false,
"Inability to absorb nutrients": false,
"Distinctive bumps": false,
"Warts": false,
"Stunted growth": false,
"Edema in the comb": false,
"Discoloration": false,
"Coughing and sneezing": false,
"Swelling": false,
"Rales": false,
"Gasping": false,
"Muscular tremors": false,
"Opisthotonus": false,
"Closed eyes": false,
"Facial swelling": false,
"Increased thirst": false,
"Lethargy": false,
"Profuse tear secretion": false,
"Facial skin edema": false,
"Progressing tremors": false,
"Drowsy": false,
"Head droop": false,
"Laying on ground": false,
"Thick large white patches on the inside the mouth and crop areas": false,
"Crusty looking eyes": false,
"Hyperemic": false,
"High fever": false,
"Paralysis": false,
"Dehydration": false,
"Unkempt feathers": false,
"Yellow fecal droppings": false,
"Dullness": false,
"Reduction in the size of the egg": false,
"Rough scaly feathers": false,
"Bloated abdomen": false,
"Brittle bones": false,
"Redness or scrabs on skin": false
};
Map<String, String> symptomsListForBackend = {
"Weight loss": "weight_loss",
"Loss of appetite": "loss_of_appetite",
"Swollen joints": "swollen_joints",
"Lameness": "lameness",
"Nasal discharge": "nasal_discharge",
"Ocular discharge": "ocular_discharge",
"Ruffled feathers": "ruffled_feathers",
"Diarrhea": "diarrhea",
"Mites": "mites",
"Egg production decrease": "egg_production_decrease",
"Inability to absorb nutrients": "inability_to_absorb_nutrients",
"Distinctive bumps": "distinctive_bumps",
"Warts": "warts",
"Stunted growth": "stunted_growth",
"Edema in the comb": "edema_in_the_comb",
"Discoloration": "discoloration",
"Coughing and sneezing": "coughing_and_sneezing",
"Swelling": "swelling",
"Rales": "rales",
"Gasping": "gasping",
"Muscular tremors": "muscular_tremors",
"Opisthotonus": "opisthotonus",
"Closed eyes": "Closed_eyes",
"Facial swelling": "facial_swelling",
"Increased thirst": "increased_thirst",
"Lethargy": "lethargy",
"Profuse tear secretion": "profuse_tear_secretion",
"Facial skin edema": "facial_skin_edema",
"Progressing tremors": "progressing_tremors",
"Drowsy": "drowsy",
"Head droop": "head_droop",
"Laying on ground": "laying_on_ground",
"Thick large white patches on the inside the mouth and crop areas":
"Thick_large_white_patches_on_the_inside_the_mouth_and_crop_areas",
"Crusty looking eyes": "Crusty_looking_eyes",
"Hyperemic": "hyperemic",
"High fever": "high_fever",
"Paralysis": "paralysis",
"Dehydration": "dehydration",
"Unkempt feathers": "unkempt_feathers",
"Yellow fecal droppings": "yellow_fecal_droppings",
"Dullness": "dullness",
"Reduction in the size of the egg": "reduction_in_the_size_of_the_egg",
"Rough scaly feathers": "Rough_scaly_feathers",
"Bloated abdomen": "bloated_abdomen",
"Brittle bones": "brittle_bones",
"Redness or scrabs on skin": "redness_or_scrabs_on_skin"
};
class Validate {
String? validatemobile(value) {
if (value.isEmpty) {
return "Please enter your mobile number";
} else if (value.length != 10 || !value.startsWith("0")) {
return "The mobile number you have entered is invalid";
} else {
return null;
}
}
String? validateEmail(value) {
bool emailValid = RegExp(
r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+")
.hasMatch(value);
if (!emailValid) {
return "Email invalid";
}
}
}
import 'package:medicare/views/showPrediction.dart';
import 'package:medicare/widgets/customButton.dart';
import 'package:medicare/api/api_calls.dart';
import 'package:medicare/api/api_caller.dart';
import '../styles.dart';
import '../utils/helper.dart';
import '../utils/staticData.dart';
import '../widgets/dialog/loadingDialog.dart';
import 'package:flutter/material.dart';
import '../widgets/customAppbar.dart';
@override
void initState() {}
class AddSymptoms extends StatefulWidget {
@override
_AddSymptomsState createState() => _AddSymptomsState();
}
class _AddSymptomsState extends State<AddSymptoms> {
bool _loaded = false;
bool _gen = false;
bool buttonActive = false;
List<dynamic> finalSymptomList = [];
Map<String, bool> symptoms = {};
@override
void initState() {
_loaded = true;
initSymptoms();
super.initState();
}
initSymptoms() {
setState(() {
symptomsList.forEach((key, value) {
symptoms[key] = value;
});
finalSymptomList.clear();
});
}
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
return Scaffold(
appBar: PreferredSize(
preferredSize: const Size.fromHeight(55),
child: CustomAppbarWidget(
mainTitle: "MediCare",
leadingImg: false,
logo: false,
searchIcon: true,
),
),
body: _loaded
? GestureDetector(
onTap: () {
FocusScope.of(context).unfocus();
},
child: Container(
width: width,
height: height,
child: Column(children: [
Container(
width: width - 40,
height: height - 300,
margin: const EdgeInsets.only(top: 20, bottom: 20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
border: Border.all(color: Button2BorderColor),
color: Colors.white),
child: symptoms.isNotEmpty
? ListView(
children: symptoms.keys.map((String key) {
return CheckboxListTile(
title: Text(key),
autofocus: false,
activeColor: DefaultColor,
checkColor: Colors.white,
selected: symptoms[key]!,
value: symptoms[key]!,
onChanged: (value) {
if (value!) {
if (finalSymptomList.length < 9) {
setState(() {
symptoms[key] = value;
});
finalSymptomList
.add(symptomsListForBackend[key]);
} else {
showSnackBar(
"Please select only 5 - 10 symptoms",
context);
}
} else {
setState(() {
symptoms[key] = value;
});
finalSymptomList
.remove(symptomsListForBackend[key]);
}
if (finalSymptomList.length < 9 &&
finalSymptomList.length > 4) {
setState(() {
buttonActive = true;
});
} else {
setState(() {
buttonActive = false;
});
}
},
);
}).toList(),
)
: const Center(
child: Text("No Symptoms"),
),
),
const SizedBox(
height: 20,
),
CustomButton(
labelText: "Predict",
active: buttonActive,
onPress: () {
if (buttonActive) {
predict();
} else {
showSnackBar(
"Please select 5 - 10 symptoms", context);
}
})
]),
),
)
: loadingDialog(context),
);
}
void predict() async {
final diseaseResponse =
await ApiCalls.predictMedicineFromSymptom(symptoms: finalSymptomList);
final stageResponse = await ApiCalls.getStage(symptoms: finalSymptomList);
if (diseaseResponse.isSuccess && stageResponse.isSuccess) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => ShowPrediction(
disease: diseaseResponse.jsonBody,
stage: stageResponse.jsonBody,
),
),
);
} else {
showSnackBar(" Something went wrong", context);
}
}
}
import 'package:medicare/main.dart';
import 'package:medicare/utils/settings.dart';
import 'package:medicare/views/home.dart';
import 'package:medicare/widgets/customButton.dart';
import 'package:medicare/widgets/customTextbox.dart';
import 'package:medicare/widgets/searchBar.dart';
import '../../widgets/dialog/loadingDialog.dart';
import '../../styles.dart';
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import '../../utils/helper.dart';
import 'addSymptoms.dart';
import 'onBoarding/loginScreen.dart';
@override
void initState() {}
class Dashboard extends StatefulWidget {
_DashboardState createState() => _DashboardState();
}
class _DashboardState extends State<Dashboard> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: GestureDetector(
onTap: () {
FocusScope.of(context).unfocus();
},
child: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
margin: const EdgeInsets.only(top: 40, left: 10, right: 10),
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
margin: const EdgeInsets.only(top: 20, left: 40, right: 40),
child: Image.asset(
"assets/images/CheckenLogo.png",
),
),
Container(
alignment: Alignment.center,
margin: const EdgeInsets.only(top: 100),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
GestureDetector(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => AddSymptoms(),
),
);
},
child: Container(
width: MediaQuery.of(context).size.width / 2.5,
height: 80,
alignment: Alignment.center,
child: const Text(
"Predict with\n Symptoms",
style: SubHeadStyle,
textAlign: TextAlign.center,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(color: Button2BorderColor),
color: Colors.white,
boxShadow: [
BoxShadow(
color: DefaultColor.withOpacity(0.4),
spreadRadius: 3,
blurRadius: 7,
offset:
Offset(0, 3), // changes position of shadow
),
],
),
),
),
GestureDetector(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => HomeScreen(),
),
);
},
child: Container(
width: MediaQuery.of(context).size.width / 2.5,
height: 80,
alignment: Alignment.center,
child: const Text(
"Predict with\n Image",
style: SubHeadStyle,
textAlign: TextAlign.center,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(color: Button2BorderColor),
color: Colors.white,
boxShadow: [
BoxShadow(
color: DefaultColor.withOpacity(0.4),
spreadRadius: 3,
blurRadius: 7,
offset:
Offset(0, 3), // changes position of shadow
),
],
),
),
),
],
),
),
GestureDetector(
onTap: () {
logout();
},
child: Container(
margin: new EdgeInsets.only(top: 200),
child: const Text(
"Logout",
style: LabelStyle1,
textAlign: TextAlign.center,
),
),
),
],
),
),
),
),
);
}
logout() {
Settings.setSigned(false);
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => LoginScreen(),
),
);
}
}
import 'dart:convert';
import 'dart:io';
import 'dart:math';
import 'package:image_picker/image_picker.dart';
import 'package:medicare/utils/staticData.dart';
import 'package:medicare/views/dashboard.dart';
import 'package:medicare/widgets/customButton.dart';
import '../styles.dart';
import '../utils/helper.dart';
import '../widgets/dialog/loadingDialog.dart';
import '../widgets/navDrawer.dart';
import 'package:flutter/material.dart';
import '../widgets/customAppbar.dart';
import 'addSymptoms.dart';
import '../utils/helper.dart';
import 'package:medicare/api/api_calls.dart';
@override
void initState() {}
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
final GlobalKey<ScaffoldState> _drawerKey = GlobalKey();
final String _profileImg = 'assets/images/avatar.jpg';
List<XFile>? _imageFileList = [];
bool buttonActive = false;
String buttonText = "Select Image";
bool _gen = false;
bool isShowDisease = false;
bool isGoHome = false;
String disease = "";
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
return Scaffold(
key: _drawerKey,
appBar: PreferredSize(
preferredSize: const Size.fromHeight(55),
child: CustomAppbarWidget(
mainTitle: "Check-en",
leadingImg: true,
logo: true,
searchIcon: true,
drawerKey: _drawerKey,
),
),
drawer: NavDrawer(
profileImg: _profileImg,
),
body: GestureDetector(
onTap: () {
FocusScope.of(context).unfocus();
},
child: Container(
height: height,
width: width,
margin: const EdgeInsets.symmetric(vertical: 20, horizontal: 10),
child: Column(children: [
GestureDetector(
onTap: () {
addImage();
},
child: Container(
width: width,
height: 92,
margin: const EdgeInsets.only(right: 20, left: 20),
padding: const EdgeInsets.only(top: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
border: Border.all(color: Button2BorderColor, width: 1.5),
),
child: Column(
children: [
Image.asset(
'assets/icons/addImage.png',
width: 50,
height: 50,
fit: BoxFit.contain,
),
const Text("Pick images of symptoms"),
],
),
),
),
Container(
margin: const EdgeInsets.symmetric(vertical: 10),
),
_gen
? genList()
: Container(
alignment: Alignment.center,
height: MediaQuery.of(context).size.height / 2 + 50,
child: const Text(
"Please select an image",
style: LabelStyle1,
),
),
const SizedBox(
height: 20,
),
CustomButton(
labelText: buttonText,
active: buttonActive,
onPress: () {
if (isGoHome) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => Dashboard(),
),
);
} else {
showDisease();
}
},
),
]),
),
),
);
}
genList() {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height / 4,
child: SingleChildScrollView(
child: Wrap(
runSpacing: 4,
spacing: 4,
alignment: WrapAlignment.center,
children: List.generate(_imageFileList!.length, (index) {
return Stack(
children: [
Container(
width: 150,
height: 150,
margin: const EdgeInsets.all(5),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
border: Border.all(color: Button2BorderColor)),
child: ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: Image.file(File(_imageFileList![index].path),
fit: BoxFit.cover),
),
),
GestureDetector(
onTap: () {
setState(() {
removeImage(index);
});
},
child: Container(
margin: const EdgeInsets.only(left: 2, top: 2),
child: Image.asset('assets/icons/remove.png',
width: 15, height: 15, fit: BoxFit.cover),
),
),
],
);
}),
),
),
),
isShowDisease
? SizedBox(
width: MediaQuery.of(context).size.width,
height: 200,
child: Text(
disease,
textAlign: TextAlign.center,
style: HeaderStyle3,
),
)
: SizedBox(
width: MediaQuery.of(context).size.width,
height: 200,
)
],
);
}
void setGen() {
if (_imageFileList!.isNotEmpty) {
_gen = true;
} else {
buttonText = "Select Image";
_gen = false;
}
if (_imageFileList!.length >= 1) {
buttonActive = true;
}
setState(() {});
}
Future<void> addImage() async {
_imageFileList = await Helper.selectImages();
setGen();
}
void removeImage(int index) {
_imageFileList!.removeAt(index);
setGen();
}
showDisease() {
if (_imageFileList!.length < 1) {
showSnackBar("Please select an image", context);
} else {
setState(() {
buttonText = "Preparing";
buttonActive = false;
});
Future.delayed(const Duration(milliseconds: 2000), () {
setState(() {
buttonActive = false;
buttonText = "Processing";
});
}).then((value) => getDisease());
}
}
getDisease() {
if (disease == "") {
final _random = new Random();
disease = diseases[_random.nextInt(diseases.length)];
}
setState(() {
isShowDisease = true;
buttonText = "Home";
buttonActive = true;
isGoHome = true;
});
}
}
import 'package:medicare/widgets/customButton.dart';
import 'package:medicare/widgets/customTextbox.dart';
import 'package:medicare/widgets/searchBar.dart';
import '../../widgets/dialog/loadingDialog.dart';
import '../dashboard.dart';
import '../home.dart';
import '../../styles.dart';
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import '../../utils/helper.dart';
@override
void initState() {}
class LoginScreen extends StatefulWidget {
_LoginScreenState createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
GlobalKey<FormState> _formKey = GlobalKey<FormState>();
TextEditingController _emailAddress = TextEditingController();
TextEditingController _password = TextEditingController();
bool buttonActive = false;
@override
Widget build(BuildContext context) {
return Scaffold(
body: GestureDetector(
onTap: () {
FocusScope.of(context).unfocus();
},
child: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
margin: const EdgeInsets.only(top: 40, left: 10, right: 10),
child: SingleChildScrollView(
child: Column(
children: [
Container(
margin: const EdgeInsets.only(top: 20, left: 40, right: 40),
child: Image.asset(
"assets/images/CheckenLogo.png",
),
),
Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
margin: const EdgeInsets.all(10),
child: Form(
key: _formKey,
child: Column(
children: [
const SizedBox(
height: 30,
),
CustomTextBox(
controller: _emailAddress,
labelText: "Please enter email",
suffixIcon: const Icon(
Icons.account_circle,
color: DefaultColor,
size: 24,
),
),
CustomTextBox(
controller: _password,
obscureText: true,
keyboardType: TextInputType.visiblePassword,
labelText: "Please enter password",
suffixIcon: const Icon(
Icons.key,
color: DefaultColor,
size: 24,
),
),
const SizedBox(
height: 20,
),
CustomButton(
labelText: "Login ",
active: true,
onPress: () {
loginRegisterCheck();
}),
],
),
),
)
],
),
),
),
),
);
}
loginRegisterCheck() {
if (_emailAddress.text == "checken@gmail.com" &&
_password.text == "123456") {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => Dashboard(),
),
);
} else {
showSnackBar("Invalid Login", context);
}
}
}
import 'package:medicare/utils/settings.dart';
import 'package:medicare/views/dashboard.dart';
import 'package:medicare/views/onBoarding/loginScreen.dart';
import '../../styles.dart';
import 'package:flutter/material.dart';
import 'package:flutter_animator/flutter_animator.dart';
import '../home.dart';
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
bool? signed = false;
@override
void initState() {
super.initState();
checkNavigation();
}
checkNavigation() async {
signed = await Settings.getSigned() == null
? false
: (await Settings.getSigned())!;
Future.delayed(const Duration(seconds: 1), () {
if (signed!) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => Dashboard(),
),
);
} else {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => LoginScreen(),
),
);
}
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Container(
color: Colors.white,
height: double.infinity,
width: MediaQuery.of(context).size.width,
child: Stack(
children: <Widget>[
Pulse(
preferences: const AnimationPreferences(
offset: Duration(seconds: 1),
autoPlay: AnimationPlayStates.Loop),
child: Container(
alignment: const Alignment(0.0, 0.0),
child: Container(
margin: const EdgeInsets.all(40),
child: ClipRRect(
borderRadius: BorderRadius.circular(20.0),
child: Image.asset(
'assets/images/CheckenLogo.png',
fit: BoxFit.fitWidth,
),
),
),
),
),
],
),
),
),
),
);
}
}
import 'package:medicare/main.dart';
import 'package:medicare/widgets/customButton.dart';
import 'package:medicare/api/api_calls.dart';
import '../../styles.dart';
import 'package:flutter/material.dart';
import '../utils/helper.dart';
import 'dashboard.dart';
@override
void initState() {}
class ShowPrediction extends StatefulWidget {
String disease;
String stage;
ShowPrediction({
required this.disease,
required this.stage,
});
_ShowPredictionState createState() => _ShowPredictionState();
}
class _ShowPredictionState extends State<ShowPrediction> {
bool buttonActive = false;
String _medicine = "";
String buttonText = "Medication";
@override
Widget build(BuildContext context) {
return Scaffold(
body: GestureDetector(
onTap: () {
FocusScope.of(context).unfocus();
},
child: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
margin: const EdgeInsets.only(top: 40, left: 10, right: 10),
child: SingleChildScrollView(
child: Column(
children: [
Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
margin: const EdgeInsets.all(10),
child: Column(
children: [
const SizedBox(
height: 50,
),
Row(
children: [
Container(
height: 2,
width: MediaQuery.of(context).size.width / 7,
color: Colors.black26,
),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 20),
child: Text(
"Predicted Disease",
style: HeaderStyle2,
),
),
Container(
height: 2,
width: MediaQuery.of(context).size.width / 7,
color: Colors.black26,
),
],
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20, vertical: 50),
child: Text(
widget.disease,
style: HeaderStyle3,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
height: 2,
width: MediaQuery.of(context).size.width / 3.5,
color: Colors.black26,
),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 20),
child: Text(
"Stage",
style: HeaderStyle2,
),
),
Container(
height: 2,
width: MediaQuery.of(context).size.width / 3.5,
color: Colors.black26,
),
],
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20, vertical: 50),
child: Text(
widget.stage,
style: HeaderStyle3,
),
),
Container(
height: 2,
width: MediaQuery.of(context).size.width,
padding: const EdgeInsets.symmetric(horizontal: 20),
color: Colors.black26,
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20, vertical: 50),
child: Text(
_medicine,
style: LabelStyle1,
),
),
CustomButton(
labelText: buttonText,
active: true,
onPress: () {
if (buttonText == "Home") {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => Dashboard(),
),
);
} else {
predict();
}
}),
],
),
)
],
),
),
),
),
);
}
void predict() async {
final medsResponse = await ApiCalls.getMedicine(
disease: widget.disease, stage: widget.stage);
if (medsResponse.isSuccess) {
setState(() {
_medicine = medsResponse.jsonBody.toString();
buttonText = "Home";
});
} else {
showSnackBar(" Something went wrong", context);
}
}
}
import '../../styles.dart';
import 'package:flutter/material.dart';
class BigVerticalCard extends StatelessWidget {
String adID;
String adImg;
String adModel;
String adBrand;
String adCatagory;
String adPrice;
BigVerticalCard({
required this.adID,
required this.adImg,
this.adBrand = "",
this.adModel = "",
this.adCatagory = "",
required this.adPrice,
});
@override
Widget build(BuildContext context) {
return Stack(
children: [
Container(
width: 170,
height: 220,
margin: EdgeInsets.only(left: 15, right: 10, top: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(color: Button2BorderColor),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.4),
spreadRadius: 3,
blurRadius: 7,
offset: Offset(0, 3), // changes position of shadow
),
],
),
child: Stack(
children: [
Container(
width: 170,
height: 140,
decoration:
BoxDecoration(borderRadius: BorderRadius.circular(5)),
child: ClipRRect(
child: adImg.isNotEmpty
? Image.network(
adImg,
fit: BoxFit.cover,
)
: Image.asset(
'assets/images/avatar.jpg',
fit: BoxFit.cover,
),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10)),
),
),
Container(
height: 30,
width: double.infinity,
margin: EdgeInsets.only(top: 150, left: 6, right: 2),
child: Text(
adModel,
style: TextStyle(
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.w600),
),
),
adBrand != ""
? Container(
height: 30,
width: double.infinity,
margin: EdgeInsets.only(top: 175, left: 6, right: 2),
child: Text(
adBrand,
style: TextStyle(color: Colors.black, fontSize: 14),
),
)
: Container(),
adCatagory != ""
? Container(
height: 30,
width: double.infinity,
margin: EdgeInsets.only(top: 175, left: 6, right: 2),
child: Text(
adCatagory,
style: TextStyle(color: Colors.black, fontSize: 14),
),
)
: Container(),
Container(
height: 30,
width: double.infinity,
margin: EdgeInsets.only(top: 195, left: 6, right: 2),
child: Text(
adPrice,
maxLines: 2,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w500,
fontSize: 14),
),
)
],
),
)
],
);
}
}
import 'package:flutter/material.dart';
import '../../styles.dart';
class CustomAppbarWidget extends StatefulWidget {
String mainTitle = "Riyasewana";
bool leadingImg;
bool logo;
bool searchIcon;
GlobalKey<ScaffoldState>? drawerKey = GlobalKey();
CustomAppbarWidget(
{required this.mainTitle,
required this.leadingImg,
required this.logo,
required this.searchIcon,
this.drawerKey});
@override
_CustomAppbarWidgetState createState() => new _CustomAppbarWidgetState();
}
class _CustomAppbarWidgetState extends State<CustomAppbarWidget> {
@override
Widget build(BuildContext context) {
return AppBar(
backgroundColor: Colors.white,
leading: widget.leadingImg
? Container()
: GestureDetector(
onTap: () => {Navigator.of(context).pop()},
child: Image.asset('assets/icons/arrow-left.png'),
),
title: widget.logo
? Padding(
padding: const EdgeInsets.only(left: 20),
child:
Image.asset('assets/images/ChekenLogoSmall.png', height: 200),
)
: Center(
child: Container(
margin: const EdgeInsets.only(right: 40),
child: Text(
widget.mainTitle,
style: HeaderStyle,
),
),
),
);
}
}
import '../../styles.dart';
import 'package:flutter/material.dart';
class CustomButton extends StatelessWidget {
String? labelText;
bool active = false;
void Function()? onPress;
CustomButton(
{required this.labelText, required this.onPress, required this.active});
@override
Widget build(BuildContext context) {
return Container(
width: 200,
decoration: BoxDecoration(
color: active ? DefaultColor : InactiveColor,
borderRadius: BorderRadius.circular(40),
),
child: TextButton(
style: TextButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 20),
primary: Colors.white,
textStyle: const TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
),
onPressed: onPress,
child: Text(labelText!),
),
);
}
}
import 'package:flutter/material.dart';
import 'package:dropdown_search/dropdown_search.dart';
import '../../styles.dart';
class CustomDropDown extends StatefulWidget {
String hint, itemValue;
List<String> itemList;
final ValueSetter<String>? newValue;
String? Function(dynamic)? validator;
CustomDropDown(
{Key? key,
this.validator,
required this.itemValue,
required this.itemList,
required this.hint,
this.newValue})
: super(key: key);
@override
_CustomDropDownState createState() => _CustomDropDownState();
}
class _CustomDropDownState extends State<CustomDropDown> {
static InputBorder errorBorder =
const OutlineInputBorder(borderSide: BorderSide(color: Colors.red));
static InputBorder enabledBorder = const OutlineInputBorder(
borderSide: BorderSide(
color: Color(0xFFA5A5A5),
),
);
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.only(left: 15, right: 15, bottom: 15),
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.0),
),
child: DropdownSearch<String>(
mode: Mode.MENU,
showSearchBox: true,
items: widget.itemList,
validator: widget.validator,
onChanged: (value) => widget.newValue!(value!),
selectedItem: widget.itemValue,
dropdownSearchDecoration: InputDecoration(
labelText: widget.hint,
hintText: widget.hint,
focusedBorder: enabledBorder,
enabledBorder: enabledBorder,
errorBorder: errorBorder,
contentPadding:
const EdgeInsets.only(left: 20, right: 10, top: 0.0, bottom: 0.0),
),
),
);
}
}
import '../../styles.dart';
import 'package:flutter/material.dart';
class CustomTextBox extends StatelessWidget {
TextEditingController controller;
TextCapitalization textCapitalization;
TextInputType keyboardType;
bool readOnly;
bool enabled;
int minLine;
int maxLine;
TextStyle hintStyle;
String labelText;
Icon suffixIcon;
bool obscureText;
String? Function(dynamic)? validator;
CustomTextBox({
required this.controller,
required this.labelText,
required this.suffixIcon,
this.validator,
this.textCapitalization = TextCapitalization.none,
this.keyboardType = TextInputType.text,
this.readOnly = false,
this.enabled = true,
this.minLine = 1,
this.maxLine = 1,
this.hintStyle = HintStyle1,
this.obscureText = false,
});
static InputBorder enabledBorder = const OutlineInputBorder(
borderSide: BorderSide(
color: Color(0xffDFDFDF),
),
);
static InputBorder errorBorder =
const OutlineInputBorder(borderSide: BorderSide(color: Colors.red));
@override
Widget build(BuildContext context) {
return Container(
height: 50,
width: MediaQuery.of(context).size.width,
margin: const EdgeInsets.only(bottom: 15),
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0.0),
decoration: BoxDecoration(
color: DefaultColor,
borderRadius: BorderRadius.circular(20),
),
child: TextFormField(
style: const TextStyle(fontSize: 16.0),
maxLines: maxLine,
minLines: minLine,
keyboardType: keyboardType,
autofocus: false,
textCapitalization: textCapitalization,
validator: validator,
controller: controller,
obscureText: obscureText,
readOnly: readOnly,
decoration: InputDecoration(
suffixIcon: suffixIcon,
filled: true,
fillColor: Colors.grey[50],
labelText: labelText,
labelStyle: LabelStyle1,
contentPadding: const EdgeInsets.fromLTRB(25.0, 0.0, 20.0, 10.0),
enabledBorder: enabledBorder,
focusedBorder: const UnderlineInputBorder(
borderSide: BorderSide(color: Colors.transparent),
),
errorBorder: errorBorder,
focusedErrorBorder: errorBorder,
enabled: enabled,
),
),
);
}
}
import 'package:flutter/material.dart';
import '../../styles.dart';
confirmDeletePopup(BuildContext context, String type, dynamic Function() delete,
dynamic Function() discard) {
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return Dialog(
elevation: 0.0,
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
child: Container(
height: 150.0,
padding: const EdgeInsets.all(10.0),
decoration: BoxDecoration(
border: Border.all(color: Colors.black26, width: 2),
borderRadius: const BorderRadius.all(Radius.circular(20)),
color: Colors.white,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(top: 40),
child: Text(
'Delete $type?',
style: LogOut,
),
),
SizedBox(
height: 40.0,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: discard,
child: Container(
width: 140,
alignment: Alignment.center,
child: Text("Back", style: greyNormalTextStyle)),
),
GestureDetector(
onTap: delete,
child: Container(
width: 140,
alignment: Alignment.center,
child: const Text("Delete", style: SeeAllStyle)),
),
],
),
)
],
),
),
);
},
);
}
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import '../../styles.dart';
loadingDialog(BuildContext context) {
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return Dialog(
backgroundColor: Colors.transparent,
insetPadding: const EdgeInsets.all(10),
child: Center(
child: SpinKitFoldingCube(
itemBuilder: (BuildContext context, int index) {
return DecoratedBox(
decoration: BoxDecoration(
color: index.isEven ? DefaultColor : InactiveColor,
),
);
},
),
),
);
},
);
}
import 'package:flutter/material.dart';
import '../../styles.dart';
saveDiscardPopup(BuildContext context, String type, dynamic Function() save,
dynamic Function() discard) {
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return Dialog(
elevation: 0.0,
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
child: Container(
height: 150.0,
padding: const EdgeInsets.all(10.0),
decoration: BoxDecoration(
border: Border.all(color: Colors.black26, width: 2),
borderRadius: const BorderRadius.all(Radius.circular(20)),
color: Colors.white,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(top: 40),
child: Text(
'Discard $type?',
style: LogOut,
),
),
SizedBox(
height: 40.0,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: discard,
child: Container(
width: 140,
alignment: Alignment.center,
child: Text("Discard", style: greyNormalTextStyle)),
),
GestureDetector(
onTap: save,
child: Container(
width: 140,
alignment: Alignment.center,
child: const Text("Save", style: SeeAllStyle)),
),
],
),
)
],
),
),
);
},
);
}
import 'package:blur/blur.dart';
import 'package:flutter/material.dart';
import '../styles.dart';
import '../views/home.dart';
class NavDrawer extends StatefulWidget {
String profileImg = '';
NavDrawer({required this.profileImg});
@override
_NavDrawerScreen createState() => _NavDrawerScreen();
}
class _NavDrawerScreen extends State<NavDrawer> {
String _defaultImg = 'assets/images/nav.jpg';
String _token = "";
bool _signed = true;
// getStatus() async {
// await Settings.getSigned().then((value) => {_signed = value!});
// setState(() {});
// }
logOut() async {
// await Settings.getAccessToken().then((value) => {_token = value!});
// final response = await ApiCalls.signOut(token: _token);
// if (response.isSuccess) {
// await Settings.setSigned(false);
// await Settings.getSigned().then((value) => {_signed = value!});
// await Settings.setUserID("");
// await Settings.setAccessToken("");
// await Settings.setFName("");
// await Settings.setLName("");
// await Settings.setUserPhone("");
// await Settings.setUserEmail("");
// setState(() {});
// Fluttertoast.showToast(
// msg: "Signed out ...",
// toastLength: Toast.LENGTH_SHORT,
// gravity: ToastGravity.CENTER,
// );
// Navigator.of(context).pop();
// } else {
// Fluttertoast.showToast(
// msg: "Signed out ...",
// toastLength: Toast.LENGTH_SHORT,
// gravity: ToastGravity.CENTER,
// );
// }
}
@override
void initState() {
// getStatus();
}
@override
Widget build(BuildContext context) {
return Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
Stack(
children: [
Blur(
blur: 3.5,
blurColor: Colors.black,
child: Container(
color: Colors.white,
height: 220,
width: 310,
child: Image.asset(
widget.profileImg,
fit: BoxFit.cover,
),
),
),
Container(
height: 80,
width: 80,
margin: EdgeInsets.only(top: 120, left: 20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
color: Colors.white,
),
child: ClipRRect(
child: Image.asset(
widget.profileImg,
fit: BoxFit.cover,
),
borderRadius: BorderRadius.circular(40),
),
),
Container(
color: DefaultColor,
width: double.infinity,
height: 4,
margin: EdgeInsets.only(top: 220),
)
],
),
const SizedBox(
height: 20,
),
ListTile(
leading: Image.asset(
'assets/icons/home-grey.png',
),
title: Text('Home'),
onTap: () => {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => HomeScreen(),
),
)
},
),
Container(
child: _signed
? GestureDetector(
onTap: () => {logOut()},
child: Container(
margin: const EdgeInsets.only(left: 117, top: 280),
child: const Text(
"Sign out",
style: LogOut,
),
),
)
: const SizedBox(height: 2),
),
GestureDetector(
child: Container(
margin: _signed
? const EdgeInsets.only(left: 120, top: 20)
: const EdgeInsets.only(left: 120, top: 320),
child: const Text(
"Donate",
style: SeeAllStyle,
),
),
)
],
),
);
}
}
import '../../styles.dart';
import 'package:flutter/material.dart';
class SearchBox extends StatelessWidget {
TextEditingController controller;
TextCapitalization textCapitalization;
TextInputType keyboardType;
bool readOnly;
bool enabled;
int minLine;
int maxLine;
String hint;
TextStyle hintStyle;
String labelText;
Icon prifixIcon;
bool obscureText;
String? Function(dynamic)? validator;
SearchBox({
required this.controller,
required this.hint,
this.validator,
this.textCapitalization = TextCapitalization.none,
this.keyboardType = TextInputType.text,
this.readOnly = false,
this.enabled = true,
this.minLine = 1,
this.maxLine = 1,
this.hintStyle = HintStyle1,
required this.labelText,
required this.prifixIcon,
this.obscureText = false,
});
static InputBorder enabledBorder = const OutlineInputBorder(
borderSide: BorderSide(
color: Color(0xffDFDFDF),
),
);
static InputBorder errorBorder =
const OutlineInputBorder(borderSide: BorderSide(color: Colors.red));
@override
Widget build(BuildContext context) {
return Stack(children: [
Container(
margin: const EdgeInsets.only(left: 15, right: 15, bottom: 15),
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0.0),
child: TextFormField(
style: const TextStyle(fontSize: 16.0),
maxLines: maxLine,
minLines: minLine,
keyboardType: keyboardType,
autofocus: false,
textCapitalization: textCapitalization,
validator: validator,
controller: controller,
obscureText: obscureText,
readOnly: readOnly,
decoration: InputDecoration(
filled: true,
fillColor: Colors.grey[50],
hintText: hint,
hintStyle: HintStyle1,
labelText: labelText,
labelStyle: LabelStyle1,
contentPadding: const EdgeInsets.fromLTRB(25.0, 0.0, 20.0, 10.0),
enabledBorder: enabledBorder,
// focusedBorder: enabledBorder,
errorBorder: errorBorder,
focusedErrorBorder: errorBorder,
enabled: enabled,
),
),
),
Container(
width: 35,
height: 35,
margin: const EdgeInsets.only(left: 325, top: 7),
child: prifixIcon,
)
]);
}
}
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:medicare/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment