Refactor - removed duplicate code

This commit is contained in:
Imran Remtulla
2022-12-04 17:12:10 -05:00
parent d934ce2e13
commit 3951108bc9

View File

@@ -219,6 +219,9 @@ class AppsPageState extends State<AppsPage> {
SliverList( SliverList(
delegate: SliverChildBuilderDelegate( delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) { (BuildContext context, int index) {
String? changesUrl = SourceProvider()
.getSource(sortedApps[index].app.url)
.changeLogPageFromStandardUrl(sortedApps[index].app.url);
return ListTile( return ListTile(
tileColor: sortedApps[index].app.pinned tileColor: sortedApps[index].app.pinned
? Colors.grey.withOpacity(0.1) ? Colors.grey.withOpacity(0.1)
@@ -274,22 +277,10 @@ class AppsPageState extends State<AppsPage> {
sortedApps[index].app.installedVersion != sortedApps[index].app.installedVersion !=
sortedApps[index].app.latestVersion sortedApps[index].app.latestVersion
? GestureDetector( ? GestureDetector(
onTap: SourceProvider() onTap: changesUrl == null
.getSource(
sortedApps[index].app.url)
.changeLogPageFromStandardUrl(
sortedApps[index].app.url) ==
null
? null ? null
: () { : () {
launchUrlString( launchUrlString(changesUrl,
SourceProvider()
.getSource(
sortedApps[index].app.url)
.changeLogPageFromStandardUrl(
sortedApps[index]
.app
.url)!,
mode: LaunchMode mode: LaunchMode
.externalApplication); .externalApplication);
}, },
@@ -297,15 +288,7 @@ class AppsPageState extends State<AppsPage> {
'${tr('updateAvailable')}${sortedApps[index].app.trackOnly ? ' ${tr('estimateInBracketsShort')}' : ''}', '${tr('updateAvailable')}${sortedApps[index].app.trackOnly ? ' ${tr('estimateInBracketsShort')}' : ''}',
style: TextStyle( style: TextStyle(
fontStyle: FontStyle.italic, fontStyle: FontStyle.italic,
decoration: SourceProvider() decoration: changesUrl == null
.getSource(sortedApps[index]
.app
.url)
.changeLogPageFromStandardUrl(
sortedApps[index]
.app
.url) ==
null
? TextDecoration.none ? TextDecoration.none
: TextDecoration.underline), : TextDecoration.underline),
)) ))