Skip to content

Commit

Permalink
[job_detail_screen] Remove refresh indicator to reload job description
Browse files Browse the repository at this point in the history
  • Loading branch information
ngomile committed Aug 25, 2023
1 parent 25c3f0a commit 74964c1
Showing 1 changed file with 64 additions and 69 deletions.
133 changes: 64 additions & 69 deletions lib/screens/job_detail_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -251,85 +251,80 @@ class _DescriptionSectionState extends State<DescriptionSection>
@override
Widget build(BuildContext context) {
super.build(context);
return RefreshIndicator(
onRefresh: () async {
_getJob(context);
},
child: SingleChildScrollView(
child: Column(
children: [
JobLeadSection(
widget.job,
initialIndex: getSources().indexWhere(
(element) => element.title == widget.source.title),
return SingleChildScrollView(
child: Column(
children: [
JobLeadSection(
widget.job,
initialIndex: getSources()
.indexWhere((element) => element.title == widget.source.title),
),
Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: BlocProvider(
create: (_) => JobDescriptionBloc()
..add(
FetchJobDescription(
job: widget.job,
source: widget.source,
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: BlocProvider(
create: (_) => JobDescriptionBloc()
..add(
FetchJobDescription(
job: widget.job,
source: widget.source,
),
child: BlocConsumer<JobDescriptionBloc, JobDescriptionState>(
listener: (context, jobDescriptionState) {},
builder: (context, jobDescriptionState) {
return switch (jobDescriptionState) {
JobDescriptionLoaded(job: final job) => switch (
job.description.isNotEmpty) {
true => HtmlWidget(
job.description,
textStyle: const TextStyle(
fontSize: 14.0,
),
onTapUrl: (url) async {
url = url
.replaceAll(RegExp('mailto:'), '')
.trim();
if (url.contains('@')) {
final emailUri = Uri(
scheme: 'mailto',
path: url,
query: _encodeQueryParameters(
{
'subject': widget.job.position,
},
),
);
),
child: BlocConsumer<JobDescriptionBloc, JobDescriptionState>(
listener: (context, jobDescriptionState) {},
builder: (context, jobDescriptionState) {
return switch (jobDescriptionState) {
JobDescriptionLoaded(job: final job) => switch (
job.description.isNotEmpty) {
true => HtmlWidget(
job.description,
textStyle: const TextStyle(
fontSize: 14.0,
),
onTapUrl: (url) async {
url = url
.replaceAll(RegExp('mailto:'), '')
.trim();
if (url.contains('@')) {
final emailUri = Uri(
scheme: 'mailto',
path: url,
query: _encodeQueryParameters(
{
'subject': widget.job.position,
},
),
);

if (await canLaunchUrl(emailUri)) {
await launchUrl(emailUri);
}
if (await canLaunchUrl(emailUri)) {
await launchUrl(emailUri);
}
}

return true;
},
),
_ => Container()
},
JobDescriptionError(error: final error) => Center(
child: ErrorButton(
errorMessage: error,
onRetryPressed: () => _onRetryPressed(context),
return true;
},
),
_ => Container()
},
JobDescriptionError(error: final error) => Center(
child: ErrorButton(
errorMessage: error,
onRetryPressed: () => _onRetryPressed(context),
),
_ => const Center(
child: CircularProgressIndicator(),
),
};
},
),
),
_ => const Center(
child: CircularProgressIndicator(),
),
};
},
),
),
),
],
),
),
],
),
);
}
Expand Down

0 comments on commit 74964c1

Please sign in to comment.