api intigreted of scan Qr and recent scan histoy ,scan history,scan history details

This commit is contained in:
Raj.Ghag
2026-04-17 15:55:54 +05:30
parent f301585948
commit 94cd74a135
60 changed files with 3678 additions and 1119 deletions

View File

@@ -0,0 +1,99 @@
import 'dart:io';
import 'package:equatable/equatable.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:image_picker/image_picker.dart'; // Import ImagePicker
import '../../repository/raise_ticket_repository.dart';
part 'raise_ticket_event.dart';
part 'raise_ticket_state.dart';
class RaiseTicketBloc extends Bloc<RaiseTicketEvent, RaiseTicketState> {
final RaiseTicketRepository _raiseTicketRepository;
final ImagePicker _picker = ImagePicker(); // Initialize ImagePicker
static const int _maxFileSizeInBytes = 5 * 1024 * 1024; // 5 MB limit
RaiseTicketBloc({RaiseTicketRepository? raiseTicketRepository})
: _raiseTicketRepository =
raiseTicketRepository ?? RaiseTicketRepository(),
super(const RaiseTicketState()) {
on<RaiseTicketSubjectChanged>(_onSubjectChanged);
on<RaiseTicketDescriptionChanged>(_onDescriptionChanged);
on<RaiseTicketAttachmentPicked>(_onAttachmentPicked);
on<RaiseTicketAttachmentRemoved>(_onAttachmentRemoved);
on<RaiseTicketSubmitted>(_onRaiseTicketSubmitted);
on<RaiseTicketReset>(_onReset);
}
void _onSubjectChanged(
RaiseTicketSubjectChanged event, Emitter<RaiseTicketState> emit) {
emit(state.copyWith(subject: event.subject));
}
void _onDescriptionChanged(
RaiseTicketDescriptionChanged event, Emitter<RaiseTicketState> emit) {
emit(state.copyWith(description: event.description));
}
Future<void> _onAttachmentPicked(
RaiseTicketAttachmentPicked event, Emitter<RaiseTicketState> emit) async {
// The event now passes the File directly after it's picked in the UI
final File file = event.attachment;
final int fileSize = await file.length();
if (fileSize > _maxFileSizeInBytes) {
emit(state.copyWith(
attachment: null,
fileSizeExceeded: true,
errorMessage: "File size exceeds 5MB limit.",
));
} else {
emit(state.copyWith(
attachment: file,
fileSizeExceeded: false,
errorMessage: null,
));
}
}
void _onAttachmentRemoved(
RaiseTicketAttachmentRemoved event, Emitter<RaiseTicketState> emit) {
emit(state.copyWith(
clearAttachment: true,
fileSizeExceeded: false,
errorMessage: null,
));
}
Future<void> _onRaiseTicketSubmitted(
RaiseTicketSubmitted event, Emitter<RaiseTicketState> emit) async {
if (state.subject.isEmpty || state.description.isEmpty) {
emit(state.copyWith(
errorMessage: "Subject and description cannot be empty."));
return;
}
if (state.fileSizeExceeded) {
emit(state.copyWith(errorMessage: "Cannot submit: file size exceeded."));
return;
}
emit(state.copyWith(status: RaiseTicketStatus.loading, errorMessage: null));
try {
await _raiseTicketRepository.raiseTicket(
subject: state.subject,
description: state.description,
attachment: state.attachment,
);
emit(state.copyWith(status: RaiseTicketStatus.success));
} catch (e) {
emit(state.copyWith(
status: RaiseTicketStatus.failure,
errorMessage: e.toString(),
));
}
}
void _onReset(
RaiseTicketReset event, Emitter<RaiseTicketState> emit) {
emit(const RaiseTicketState());
}
}

View File

@@ -0,0 +1,44 @@
part of 'raise_ticket_bloc.dart';
abstract class RaiseTicketEvent extends Equatable {
const RaiseTicketEvent();
@override
List<Object?> get props => [];
}
class RaiseTicketSubjectChanged extends RaiseTicketEvent {
final String subject;
const RaiseTicketSubjectChanged(this.subject);
@override
List<Object> get props => [subject];
}
class RaiseTicketDescriptionChanged extends RaiseTicketEvent {
final String description;
const RaiseTicketDescriptionChanged(this.description);
@override
List<Object> get props => [description];
}
class RaiseTicketAttachmentPicked extends RaiseTicketEvent {
final File attachment;
const RaiseTicketAttachmentPicked(this.attachment);
@override
List<Object> get props => [attachment];
}
class RaiseTicketAttachmentRemoved extends RaiseTicketEvent {
const RaiseTicketAttachmentRemoved();
}
class RaiseTicketSubmitted extends RaiseTicketEvent {
const RaiseTicketSubmitted();
}
class RaiseTicketReset extends RaiseTicketEvent {
const RaiseTicketReset();
}

View File

@@ -0,0 +1,43 @@
part of 'raise_ticket_bloc.dart';
enum RaiseTicketStatus { initial, loading, success, failure }
class RaiseTicketState extends Equatable {
final RaiseTicketStatus status;
final String subject;
final String description;
final File? attachment;
final bool fileSizeExceeded;
final String? errorMessage;
const RaiseTicketState({
this.status = RaiseTicketStatus.initial,
this.subject = '',
this.description = '',
this.attachment,
this.fileSizeExceeded = false,
this.errorMessage,
});
RaiseTicketState copyWith({
RaiseTicketStatus? status,
String? subject,
String? description,
File? attachment,
bool clearAttachment = false,
bool? fileSizeExceeded,
String? errorMessage,
}) {
return RaiseTicketState(
status: status ?? this.status,
subject: subject ?? this.subject,
description: description ?? this.description,
attachment: clearAttachment ? null : attachment ?? this.attachment,
fileSizeExceeded: fileSizeExceeded ?? this.fileSizeExceeded,
errorMessage: errorMessage,
);
}
@override
List<Object?> get props => [status, subject, description, attachment, fileSizeExceeded, errorMessage];
}

View File

@@ -0,0 +1,30 @@
import 'package:equatable/equatable.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../model/support_details_model.dart';
import '../../repository/support_details_repository.dart';
part 'support_details_event.dart';
part 'support_details_state.dart';
class SupportDetailsBloc extends Bloc<SupportDetailsEvent, SupportDetailsState> {
final SupportDetailsRepository _repository;
SupportDetailsBloc({SupportDetailsRepository? repository})
: _repository = repository ?? SupportDetailsRepository(),
super(const SupportDetailsInitial()) {
on<FetchSupportDetailsEvent>(_onFetchSupportDetails);
}
Future<void> _onFetchSupportDetails(
FetchSupportDetailsEvent event,
Emitter<SupportDetailsState> emit,
) async {
emit(const SupportDetailsLoading());
try {
final SupportDetailModel data = await _repository.fetchSupportDetails();
emit(SupportDetailsLoaded(supportDetail: data));
} catch (e) {
emit(SupportDetailsError(message: e.toString()));
}
}
}

View File

@@ -0,0 +1,12 @@
part of 'support_details_bloc.dart';
abstract class SupportDetailsEvent extends Equatable {
const SupportDetailsEvent();
@override
List<Object?> get props => [];
}
class FetchSupportDetailsEvent extends SupportDetailsEvent {
const FetchSupportDetailsEvent();
}

View File

@@ -0,0 +1,38 @@
part of 'support_details_bloc.dart';
abstract class SupportDetailsState extends Equatable {
const SupportDetailsState();
@override
List<Object?> get props => [];
}
// Initial state before any event is fired
class SupportDetailsInitial extends SupportDetailsState {
const SupportDetailsInitial();
}
// Loading state while API call is in progress
class SupportDetailsLoading extends SupportDetailsState {
const SupportDetailsLoading();
}
// Success state with fetched data
class SupportDetailsLoaded extends SupportDetailsState {
final SupportDetailModel supportDetail;
const SupportDetailsLoaded({required this.supportDetail});
@override
List<Object?> get props => [supportDetail];
}
// Error state with a message
class SupportDetailsError extends SupportDetailsState {
final String message;
const SupportDetailsError({required this.message});
@override
List<Object?> get props => [message];
}

View File

@@ -0,0 +1,190 @@
// ================= RESPONSE WRAPPER =================
class SupportDetailResponse {
final SupportDetailModel data;
SupportDetailResponse({
required this.data,
});
factory SupportDetailResponse.fromJson(Map<String, dynamic>? json) {
return SupportDetailResponse(
data: json != null
? SupportDetailModel.fromJson(json)
: SupportDetailModel.empty(),
);
}
}
// ================= MAIN MODEL =================
class SupportDetailModel {
final int id;
final int partnerXid;
final int userXid;
final int roleXid;
final String fullName;
final String email;
final String phone;
final String round;
final bool isActive;
final bool isDeleted;
final String lastLoginAt;
final String createdAt;
final String updatedAt;
final SupportRoleModel role;
final PartnerModel partner;
SupportDetailModel({
required this.id,
required this.partnerXid,
required this.userXid,
required this.roleXid,
required this.fullName,
required this.email,
required this.phone,
required this.round,
required this.isActive,
required this.isDeleted,
required this.lastLoginAt,
required this.createdAt,
required this.updatedAt,
required this.role,
required this.partner,
});
factory SupportDetailModel.fromJson(Map<String, dynamic> json) {
return SupportDetailModel(
id: json['id'] ?? 0,
partnerXid: json['partnerXid'] ?? 0,
userXid: json['userXid'] ?? 0,
roleXid: json['roleXid'] ?? 0,
fullName: json['fullName'] ?? "N/A",
email: json['email'] ?? "N/A",
phone: json['phone'] ?? "N/A",
round: json['round'] ?? "N/A",
isActive: json['isActive'] ?? false,
isDeleted: json['isDeleted'] ?? false,
lastLoginAt: json['lastLoginAt'] ?? "N/A",
createdAt: json['createdAt'] ?? "N/A",
updatedAt: json['updatedAt'] ?? "N/A",
role: json['role'] != null
? SupportRoleModel.fromJson(json['role'])
: SupportRoleModel.empty(),
partner: json['partner'] != null
? PartnerModel.fromJson(json['partner'])
: PartnerModel.empty(),
);
}
factory SupportDetailModel.empty() {
return SupportDetailModel(
id: 0,
partnerXid: 0,
userXid: 0,
roleXid: 0,
fullName: "N/A",
email: "N/A",
phone: "N/A",
round: "N/A",
isActive: false,
isDeleted: false,
lastLoginAt: "N/A",
createdAt: "N/A",
updatedAt: "N/A",
role: SupportRoleModel.empty(),
partner: PartnerModel.empty(),
);
}
}
// ================= ROLE MODEL =================
class SupportRoleModel {
final int id;
final String name;
final bool isActive;
final String createdAt;
final String updatedAt;
SupportRoleModel({
required this.id,
required this.name,
required this.isActive,
required this.createdAt,
required this.updatedAt,
});
factory SupportRoleModel.fromJson(Map<String, dynamic> json) {
return SupportRoleModel(
id: json['id'] ?? 0,
name: json['name'] ?? "N/A",
isActive: json['isActive'] ?? false,
createdAt: json['createdAt'] ?? "N/A",
updatedAt: json['updatedAt'] ?? "N/A",
);
}
factory SupportRoleModel.empty() {
return SupportRoleModel(
id: 0,
name: "N/A",
isActive: false,
createdAt: "N/A",
updatedAt: "N/A",
);
}
Map<String, dynamic> toJson() {
return {
"id": id,
"name": name,
"isActive": isActive,
"createdAt": createdAt,
"updatedAt": updatedAt,
};
}
}
// ================= PARTNER MODEL =================
class PartnerModel {
final int id;
final String businessName;
final String emailAddress;
final String phoneNumber;
PartnerModel({
required this.id,
required this.businessName,
required this.emailAddress,
required this.phoneNumber,
});
factory PartnerModel.fromJson(Map<String, dynamic> json) {
return PartnerModel(
id: json['id'] ?? 0,
businessName: json['businessName'] ?? "N/A",
emailAddress: json['emailAddress'] ?? "N/A",
phoneNumber: json['phoneNumber'] ?? "N/A",
);
}
factory PartnerModel.empty() {
return PartnerModel(
id: 0,
businessName: "N/A",
emailAddress: "N/A",
phoneNumber: "N/A",
);
}
Map<String, dynamic> toJson() {
return {
"id": id,
"businessName": businessName,
"emailAddress": emailAddress,
"phoneNumber": phoneNumber,
};
}
}

View File

@@ -0,0 +1,38 @@
import 'dart:io';
import 'package:dio/dio.dart';
import '../../network_api_service/api_service/api_service.dart';
import '../../network_api_service/api_urls/api_urls.dart';
class RaiseTicketRepository {
final ApiService _apiService = ApiService();
Future<void> raiseTicket({
required String subject,
required String description,
File? attachment,
}) async {
try {
final Map<String, dynamic> formMap = {
"subject": subject,
"description": description,
};
if (attachment != null) {
final fileName = attachment.path.split('/').last;
formMap["attachment"] = await MultipartFile.fromFile(
attachment.path,
filename: fileName,
);
}
final formData = FormData.fromMap(formMap);
await _apiService.post(
ApiUrls.supportDetails,
data: formData,
);
} catch (e) {
rethrow;
}
}
}

View File

@@ -0,0 +1,22 @@
import '../../local_peference/local_preference.dart';
import '../../network_api_service/api_service/api_service.dart';
import '../../network_api_service/api_urls/api_urls.dart';
import '../model/support_details_model.dart';
class SupportDetailsRepository {
final ApiService _apiService = ApiService();
Future<SupportDetailModel> fetchSupportDetails() async {
try {
final userId = await LocalPreference.getUserId();
final response = await _apiService.get(
'${ApiUrls.supportDetails}/$userId',
);
return SupportDetailModel.fromJson(response.data);
} catch (e) {
throw Exception('Failed to fetch support details: $e');
}
}
}

View File

@@ -1,258 +1,355 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:google_fonts/google_fonts.dart';
import '../blocs/ticket_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:image_picker/image_picker.dart';
class SupportFormPage extends StatelessWidget {
import '../blocs/raise_ticket/raise_ticket_bloc.dart';
import '../blocs/support_details/support_details_bloc.dart';
class SupportFormPage extends StatefulWidget {
const SupportFormPage({super.key});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (_) => TicketBloc(),
child: const _SupportFormView(),
);
}
State<SupportFormPage> createState() => _SupportFormPageState();
}
class _SupportFormView extends StatelessWidget {
const _SupportFormView();
class _SupportFormPageState extends State<SupportFormPage> {
final TextEditingController _subjectController = TextEditingController();
final TextEditingController _descriptionController = TextEditingController();
final ImagePicker _picker = ImagePicker();
@override
void initState() {
super.initState();
// Trigger the fetch event for support details once when the page is initialized
context.read<SupportDetailsBloc>().add(FetchSupportDetailsEvent());
// Listen to existing state if we are coming back or resuming (optional)
final state = context.read<RaiseTicketBloc>().state;
_subjectController.text = state.subject;
_descriptionController.text = state.description;
}
@override
void dispose() {
_subjectController.dispose();
_descriptionController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final bloc = context.read<TicketBloc>();
return Scaffold(
backgroundColor: Colors.white,
bottomNavigationBar: BlocBuilder<TicketBloc, TicketState>(
builder: (context, state) {return
Visibility(
visible: MediaQuery.of(context).viewInsets.bottom == 0.0,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: SizedBox(
width: double.infinity,
height: 52,
child: ElevatedButton(
onPressed: state.isLoading
? null
: () => bloc.add(SubmitTicket()),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xffF95F62),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8)),
return BlocConsumer<RaiseTicketBloc, RaiseTicketState>(
listener: (context, state) {
if (state.status == RaiseTicketStatus.success) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Ticket submitted successfully!")),
);
_subjectController.clear();
_descriptionController.clear();
context.read<RaiseTicketBloc>().add(const RaiseTicketReset());
Navigator.pop(context);
} else if (state.status == RaiseTicketStatus.failure &&
state.errorMessage != null) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Error: ${state.errorMessage}")),
);
} else if (state.fileSizeExceeded && state.errorMessage != null) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Error: ${state.errorMessage}")),
);
// Auto-remove the invalid attachment
// context.read<RaiseTicketBloc>().add(const RaiseTicketAttachmentRemoved());
}
},
builder: (context, state) {
final raiseTicketBloc = context.read<RaiseTicketBloc>();
return Scaffold(
backgroundColor: Colors.white,
bottomNavigationBar: Visibility(
visible: MediaQuery.of(context).viewInsets.bottom == 0.0,
child: Padding(
padding: EdgeInsets.all(16.w),
child: SizedBox(
width: double.infinity,
height: 52.h,
child: ElevatedButton(
onPressed: state.status == RaiseTicketStatus.loading ||
state.fileSizeExceeded ||
state.subject.isEmpty ||
state.description.isEmpty
? null
: () => raiseTicketBloc.add(const RaiseTicketSubmitted()),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xffF95F62),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.r)),
),
child: state.status == RaiseTicketStatus.loading
? SizedBox(
width: 20.w,
height: 20.h,
child: const CircularProgressIndicator(
color: Colors.white, strokeWidth: 2),
)
: Text(
"Submit Ticket",
style: TextStyle(
color: Colors.white,
fontSize: 20.sp,
fontWeight: FontWeight.w600),
),
),
child: state.isLoading
? const CircularProgressIndicator(color: Colors.white)
: Text("Submit Ticket",
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.w600)),
),
),
),
);
}),
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
leading: Padding(
padding: EdgeInsetsGeometry.symmetric(horizontal: 8),
child: InkWell(
onTap: (){
Navigator.pop(context);
},
child: Container(
width: 44,
height: 44,
decoration: const BoxDecoration(
color: Color(0xFFF95F62),
shape: BoxShape.circle,
),
child: const Icon(Icons.arrow_back, color: Colors.white),
),
),
),
forceMaterialTransparency: true,
centerTitle: true,
title: Text("Support",
style: TextStyle(fontWeight: FontWeight.w700, color: Colors.black,fontSize: 32)),
),
body: BlocBuilder<TicketBloc, TicketState>(
builder: (context, state) {
return SingleChildScrollView(
padding: const EdgeInsets.all(20),
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
leading: Padding(
padding: EdgeInsets.symmetric(horizontal: 8.w),
child: InkWell(
onTap: () {
Navigator.pop(context);
},
child: Container(
width: 44.w,
height: 44.h,
decoration: const BoxDecoration(
color: Color(0xFFF95F62),
shape: BoxShape.circle,
),
child: Icon(Icons.arrow_back, color: Colors.white, size: 24.sp),
),
),
),
forceMaterialTransparency: true,
centerTitle: true,
title: Text("Support",
style: TextStyle(
fontWeight: FontWeight.w700,
color: Colors.black,
fontSize: 32.sp)),
),
body: SingleChildScrollView(
padding: EdgeInsets.all(20.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Align(
alignment: Alignment.center,
child: Text(
textAlign: TextAlign.center,
"Need help? Were here for you. Raise a ticket and our support team will get back to you shortly",
style: TextStyle(color: Colors.black, fontSize: 13,),
textAlign: TextAlign.center,
style: TextStyle(color: Colors.black, fontSize: 13.sp),
),
),
const SizedBox(height: 20),
Text("Subject", style: TextStyle(fontWeight: FontWeight.w500,fontSize: 14)),
const SizedBox(height: 6),
SizedBox(height: 20.h),
Text("Subject",
style: TextStyle(fontWeight: FontWeight.w500, fontSize: 14.sp)),
SizedBox(height: 6.h),
TextField(
onChanged: (v) => bloc.add(SubjectChanged(v)),
decoration: InputDecoration(
controller: _subjectController,
onChanged: (v) => raiseTicketBloc.add(RaiseTicketSubjectChanged(v)),
decoration: InputDecoration(
fillColor: Colors.black.withOpacity(0.04),
hintText: "Enter Subject",
filled: true,
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.black.withOpacity(0.24), width: 1.0),
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(
color: Colors.black.withOpacity(0.24), width: 1.0.w),
borderRadius: BorderRadius.circular(8.r),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.black.withOpacity(0.24), width: 1.0),
borderRadius: BorderRadius.circular(8),
),
disabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.black.withOpacity(0.24), width: 1.0),
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(
color: Colors.black.withOpacity(0.24), width: 1.0.w),
borderRadius: BorderRadius.circular(8.r),
),
border: OutlineInputBorder(
borderSide: BorderSide(color: Colors.black.withOpacity(0.24), width: 1.0),
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(
color: Colors.black.withOpacity(0.24), width: 1.0.w),
borderRadius: BorderRadius.circular(8.r),
),
),
),
const SizedBox(height: 20),
Text("Description", style: TextStyle(fontWeight: FontWeight.w500,fontSize: 14)),
const SizedBox(height: 6),
SizedBox(height: 20.h),
Text("Description",
style: TextStyle(fontWeight: FontWeight.w500, fontSize: 14.sp)),
SizedBox(height: 6.h),
TextField(
onChanged: (v) => bloc.add(DescriptionChanged(v)),
controller: _descriptionController,
onChanged: (v) => raiseTicketBloc.add(RaiseTicketDescriptionChanged(v)),
maxLines: 4,
decoration: InputDecoration(
decoration: InputDecoration(
fillColor: Colors.black.withOpacity(0.04),
hintText: "Enter Description",
filled: true,
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.black.withOpacity(0.24), width: 1.0),
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(
color: Colors.black.withOpacity(0.24), width: 1.0.w),
borderRadius: BorderRadius.circular(8.r),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.black.withOpacity(0.24), width: 1.0),
borderRadius: BorderRadius.circular(8),
),
disabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.black.withOpacity(0.24), width: 1.0),
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(
color: Colors.black.withOpacity(0.24), width: 1.0.w),
borderRadius: BorderRadius.circular(8.r),
),
border: OutlineInputBorder(
borderSide: BorderSide(color: Colors.black.withOpacity(0.24), width: 1.0),
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(
color: Colors.black.withOpacity(0.24), width: 1.0.w),
borderRadius: BorderRadius.circular(8.r),
),
),
),
const SizedBox(height: 20),
Text("File upload", style: TextStyle(fontWeight: FontWeight.w500,fontSize: 14)),
const SizedBox(height: 6),
SizedBox(height: 20.h),
Text("File upload",
style: TextStyle(fontWeight: FontWeight.w500, fontSize: 14.sp)),
SizedBox(height: 6.h),
GestureDetector(
onTap: () => bloc.add(UploadFile()),
onTap: () async {
// pickMedia allows both images and videos
final XFile? pickedFile = await _picker.pickMedia();
if (pickedFile != null) {
raiseTicketBloc.add(RaiseTicketAttachmentPicked(File(pickedFile.path)));
}
},
child: Container(
height: 45,
height: 45.h,
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.04),
border: Border.all(color: Colors.grey),
borderRadius: BorderRadius.circular(6),
borderRadius: BorderRadius.circular(6.r),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Text(
state.selectedFile != null
? state.selectedFile!.name
: "Upload File",
style: TextStyle(
color: state.selectedFile != null
? Colors.black
: Colors.black54,
Expanded(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Text(
state.attachment != null
? state.attachment!.path.split('/').last
: (state.fileSizeExceeded ? "File too large (>5MB).Pick another" : "Upload File"),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: state.attachment != null
? Colors.black
: (state.fileSizeExceeded ? Colors.red : Colors.black54),
fontSize: 13.sp,
),
),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Image.asset("assets/support/icon/upload.png",scale: 4,),
padding: EdgeInsets.symmetric(horizontal: 8.w),
child: Image.asset(
"assets/support/icon/upload.png",
scale: 4,
width: 24.w,
height: 24.h,
),
),
],
),
),
),
const SizedBox(height: 30),
if (state.attachment != null)
Align(
alignment: Alignment.centerRight,
child: TextButton(
onPressed: () => raiseTicketBloc.add(const RaiseTicketAttachmentRemoved()),
child: Text(
"Remove File",
style: TextStyle(color: Colors.red, fontSize: 12.sp),
),
),
),
SizedBox(height: 30.h),
Text("Contact Details",
style: TextStyle(
fontWeight: FontWeight.w600, fontSize: 24)),
const SizedBox(height: 12),
Divider(),
Row(
children: [
Expanded(
flex: 1,
child: Row(
children: [
const Icon(Icons.email_outlined, color: Colors.black87),
const SizedBox(width: 12),
Text("Email", style: TextStyle(fontSize: 13)),
],
),
),
Expanded(
flex: 2,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const SizedBox(width: 12),
Text("Lila Hart", style: TextStyle(fontSize: 13,color: Colors.black)),
],
),
),
],
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 24.sp)),
SizedBox(height: 12.h),
const Divider(),
BlocBuilder<SupportDetailsBloc, SupportDetailsState>(
builder: (context, supportState) {
String email = "Loading...";
String phone = "Loading...";
if (supportState is SupportDetailsLoaded) {
email = supportState.supportDetail.partner.emailAddress;
phone = supportState.supportDetail.partner.phoneNumber;
} else if (supportState is SupportDetailsError) {
email = "Error loading";
phone = "Error loading";
}
return Column(
children: [
Row(
children: [
Expanded(
flex: 1,
child: Row(
children: [
Icon(Icons.email_outlined, color: Colors.black87, size: 20.sp),
SizedBox(width: 12.w),
Text("Email", style: TextStyle(fontSize: 13.sp)),
],
),
),
Expanded(
flex: 2,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(width: 12.w),
Text(email,
style: TextStyle(
fontSize: 13.sp, color: Colors.black)),
],
),
),
],
),
const Divider(),
SizedBox(height: 12.h),
Row(
children: [
Expanded(
flex: 1,
child: Row(
children: [
Icon(Icons.phone_outlined, color: Colors.black87, size: 20.sp),
SizedBox(width: 12.w),
Text("Phone", style: TextStyle(fontSize: 13.sp)),
],
),
),
Expanded(
flex: 2,
child: Row(
children: [
SizedBox(width: 12.w),
Text(phone, style: TextStyle(fontSize: 13.sp)),
],
),
),
],
),
],
);
},
),
Divider(),
const SizedBox(height: 12),
Row(
children: [
Expanded(
flex: 1,
child: Row(
children: [
const Icon(Icons.phone_outlined, color: Colors.black87),
const SizedBox(width: 12),
Text("Phone", style: TextStyle(fontSize: 13)),
],
),
),
Expanded(
flex: 2,
child: Row(
children: [
const SizedBox(width: 12),
Text("(+971) 050 4245 564",
style: TextStyle(fontSize: 13)),
],
),
),
],
),
Divider(),
const SizedBox(height: 80),
const Divider(),
SizedBox(height: 80.h),
],
),
);
},
),
),
);
},
);
}
}
}