-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from Bablo-AD/dev
Dev
- Loading branch information
Showing
15 changed files
with
598 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:device_apps/device_apps.dart'; | ||
import '../core/loader.dart'; | ||
import '../core/data.dart'; | ||
|
||
class AppsPage extends StatefulWidget { | ||
const AppsPage({super.key}); | ||
|
||
@override | ||
State<AppsPage> createState() => _AppsPageState(); | ||
} | ||
|
||
class _AppsPageState extends State<AppsPage> { | ||
List<Application> filteredApps = Data.apps; | ||
@override | ||
void initState() { | ||
super.initState(); | ||
Loader.loadApps(); | ||
} | ||
|
||
void _filterApps(String query) { | ||
setState(() { | ||
filteredApps = Data.apps | ||
.where( | ||
(app) => app.appName.toLowerCase().contains(query.toLowerCase())) | ||
.toList(); | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: const Text( | ||
'Mentor/Apps', | ||
), | ||
), | ||
body: Column( | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: TextField( | ||
onChanged: _filterApps, // Call _filterApps when the text changes | ||
decoration: InputDecoration( | ||
labelText: 'Search', | ||
prefixIcon: Icon( | ||
Icons.search, | ||
), | ||
filled: true, | ||
), | ||
), | ||
), | ||
Expanded( | ||
child: ListView.builder( | ||
itemCount: filteredApps.length, | ||
itemBuilder: (context, index) { | ||
final Application app = filteredApps[index]; | ||
return Column( | ||
children: [ | ||
ListTile( | ||
onTap: () async { | ||
bool isInstalled = | ||
await DeviceApps.isAppInstalled(app.packageName); | ||
if (isInstalled) { | ||
DeviceApps.openApp(app.packageName); | ||
} | ||
}, | ||
title: Text( | ||
app.appName, | ||
style: const TextStyle( | ||
fontWeight: FontWeight.bold, | ||
), | ||
), | ||
), | ||
const SizedBox(height: 5), | ||
], | ||
); | ||
}, | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:device_apps/device_apps.dart'; | ||
import '../core/data.dart'; | ||
import '../core/loader.dart'; | ||
|
||
class AppSelectionPage extends StatefulWidget { | ||
const AppSelectionPage({super.key}); | ||
|
||
@override | ||
_AppSelectionPageState createState() => _AppSelectionPageState(); | ||
} | ||
|
||
class _AppSelectionPageState extends State<AppSelectionPage> { | ||
Loader _loader = Loader(); | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
_loader.loadSelectedApps(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: const Text( | ||
'Mentor/Apps/Selection', | ||
), | ||
), | ||
body: Column( | ||
children: [ | ||
Expanded( | ||
child: ListView.builder( | ||
itemCount: Data.apps.length, | ||
itemBuilder: (context, index) { | ||
final Application app = Data.apps[index]; | ||
return Column( | ||
children: [ | ||
CheckboxListTile( | ||
activeColor: const Color.fromARGB(255, 50, 204, 102), | ||
checkColor: const Color.fromARGB(255, 19, 19, 19), | ||
tileColor: const Color.fromARGB(255, 19, 19, 19), | ||
title: Text( | ||
app.appName, | ||
), | ||
value: Data.selected_apps.contains(app), | ||
onChanged: (bool? value) { | ||
setState(() { | ||
if (value != null && value) { | ||
Data.selected_apps.add(app); | ||
} else { | ||
Data.selected_apps.remove(app); | ||
} | ||
}); | ||
}, | ||
), | ||
const SizedBox(height: 10), | ||
], | ||
); | ||
}, | ||
), | ||
), | ||
], | ||
), | ||
floatingActionButton: FloatingActionButton( | ||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), | ||
child: const Icon(Icons.check), | ||
onPressed: () async { | ||
await _loader.saveSelectedApps(); | ||
Navigator.of(context).pop(); | ||
}, | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.