Skip to content

Commit

Permalink
Apps Loading screen and apps sorting option added
Browse files Browse the repository at this point in the history
  • Loading branch information
jspw committed Nov 18, 2020
1 parent 64476e7 commit bf4b7b4
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 107 deletions.
Binary file added assets/background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/animated logo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/ezgif.com-gif-maker.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/ubuntu-splash-screen.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/ubuntu_logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
130 changes: 87 additions & 43 deletions lib/UI/Screens/apps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,87 @@ import '../../Utility/libraries.dart';

class Apps extends StatefulWidget {
List<Application> apps;
String sortType;

Apps(this.apps);
Apps(this.apps, this.sortType);

@override
State<StatefulWidget> createState() {
// TODO: implement createState
// throw UnimplementedError();
return AppsState(apps);
return AppsState(apps, sortType);
}
}

class AppsState extends State {
List<Application> apps;
AppsState(this.apps);

Future<void> appInfo() async {
apps = await DeviceApps.getInstalledApplications(
includeAppIcons: true,
includeSystemApps: true,
onlyAppsWithLaunchIntent: true,
);
bool isSort = true;

List<String> sortTypes = [
'Alphabetically',
'Installation Time',
'UpdateTime',
];

String sortType;

AppsState(this.apps, this.sortType);

apps.sort(
(a, b) => a.appName.toLowerCase().compareTo(b.appName.toLowerCase()));
Future<void> appInfo() async {
var data = await AppInformations.appInfo(sortType);
setState(() {
apps = data;
});
}

void sortApps(String isSort) {
setState(() {
apps = apps;
if (sortType == "Alphabetically")
apps.sort((a, b) =>
a.appName.toLowerCase().compareTo(b.appName.toLowerCase()));
else if (sortType == "Installation Time")
apps.sort((b, a) => a.installTimeMillis.compareTo(b.installTimeMillis));
else if (sortType == "UpdateTime")
apps.sort((b, a) => a.updateTimeMillis.compareTo(b.updateTimeMillis));
});
print(apps);
}

Widget sortTypeList() {
return DropdownButton<String>(
// value: sortType,
icon: Icon(
Icons.sort,
color: Colors.white,
),
iconSize: 35,
elevation: 16,

style: TextStyle(color: Colors.black),
underline: Container(
// color: Colors.pink[900],
child: Text(""),
),
onChanged: (String newValue) {
setState(() {
sortType = newValue;
});

sortApps(sortType);
},
items: sortTypes.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
);
}

@override
void initState() {
appInfo();
super.initState();
}

@override
Expand All @@ -46,60 +98,52 @@ class AppsState extends State {
return Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
backgroundColor: Colors.pink.withOpacity(0.5),
backgroundColor: Colors.transparent,
title: Text(
'Applications',
style: TextStyle(fontSize: 25),
),
titleSpacing: 1.2,
centerTitle: true,
leading: GestureDetector(
onTap: () => Navigator.pop(context),
onTap: () => Navigator.pop(context, [apps, sortType]),
child: Container(
color: Colors.pink[900],
child: IconButton(
icon: Icon(
Icons.arrow_back_ios,
color: Colors.white,
size: 35.0,
),
onPressed: null),
child: Image.asset(
"assets/images/ic_launcher.png",
fit: BoxFit.cover,
),
),
),
actions: <Widget>[
sortTypeList(),
],
),
body: RefreshIndicator(
color: Colors.transparent,
onRefresh: () => appInfo(),
child: apps == null
? Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
// CircularProgressIndicator(
// backgroundColor: Colors.pink,

// valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
// ),
Container(
height: 50,
width: 50,
color: Colors.transparent,
child: Image.asset(
"assets/images/loader2.gif",
fit: BoxFit.cover,
),
),
],
child: Container(
height: 50,
width: 50,
color: Colors.transparent,
child: Image.asset(
"assets/images/loader2.gif",
fit: BoxFit.cover,
),
),
)
: GridView.count(
padding: const EdgeInsets.only(left: 50),
physics: BouncingScrollPhysics(),
crossAxisCount: 4,
children: List.generate(apps.length, (int i) {
Application app = apps[i];
return GestureDetector(
onTap: () => DeviceApps.openApp(app.packageName),
onTap: () {
DeviceApps.openApp(app.packageName);
Navigator.pop(context, [apps, sortType]);
},
child: app is ApplicationWithIcon
? GridTile(
child: Padding(
Expand Down
162 changes: 105 additions & 57 deletions lib/UI/Screens/home.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


import '../../Utility/libraries.dart';

class Home extends StatefulWidget {
Expand All @@ -16,34 +14,71 @@ class HomeState extends State {

List<Application> apps;

String sortType = "Alphabetically";

String settingsPackageName;
String cameraPackageName;
String messagesPackageName;

double sidebarOpacity = 1;

_launchCaller() async {
const url = "tel:";
const url = "tel:911";
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}

_launchSms() async {
const uri = 'sms:';
if (await canLaunch(uri)) {
await launch(uri);
} else {
// iOS
const uri = 'sms:';
if (await canLaunch(uri)) {
await launch(uri);
} else {
throw 'Could not launch $uri';
void drawerApps() async {}

void appInfo() async {
var data = await AppInformations.appInfo(sortType);
setState(() {
apps = data;
});

print(apps);

for (int i = 0; i < apps.length; i++) {
print(apps[i].appName);
}

String settingsPackageNameDemo;
String cameraPackageNameDemo;
String messagesPackageNameDemo;

for (int i = 0; i < apps.length; i++) {
Application app = apps[i];
if (app.appName == "Settings") {
settingsPackageNameDemo = app.packageName;
}
if (app.appName == "Camera") {
cameraPackageNameDemo = app.packageName;
}
if (app.appName == "Messages") {
messagesPackageNameDemo = app.packageName;
}
}

setState(() {
settingsPackageName = settingsPackageNameDemo;
cameraPackageName = cameraPackageNameDemo;
messagesPackageName = messagesPackageNameDemo;
});
}

void appInfo() async {
var data = await AppInformations.appInfo();
void navigateScreen() async {
setState(() {
apps = data;
sidebarOpacity = 0.30;
});
var app = await Navigator.of(context)
.push(RouteAnimator.createRoute(apps, sortType));
setState(() {
apps = app[0];
sortType = app[1];
sidebarOpacity = 1;
});
}

Expand All @@ -58,57 +93,70 @@ class HomeState extends State {
// TODO: implement build
// throw UnimplementedErro
return Scaffold(
drawer: Container(
color: Colors.pink.withOpacity(0.5),
height: MediaQuery.of(context).size.height,
width: 60.0,
child: Column(
children: <Widget>[
SizedBox(
height: 30.0,
),
GestureDetector(
onTap: () {
Navigator.of(context).push(RouteAnimator.createRoute(apps));
},
child: Container(
width: 35,
child: Image.asset(
"assets/images/ic_launcher.png",
fit: BoxFit.cover,
drawer: Opacity(
opacity: sidebarOpacity,
child: Container(
color: Colors.pink.withOpacity(0.5),
height: MediaQuery.of(context).size.height,
width: 60.0,
child: Column(
children: <Widget>[
SizedBox(
height: 30.0,
),
GestureDetector(
onTap: () {
navigateScreen();
},
child: Container(
width: 35,
child: Image.asset(
"assets/images/ic_launcher.png",
fit: BoxFit.cover,
),
),
),
),
buildIcons(
_launchCaller,
Icon(
Icons.call,
color: Colors.white,
buildIcons(
_launchCaller,
Icon(
Icons.call,
color: Colors.white,
),
),
),
buildIcons(
() => _launchSms,
Icon(
Icons.message,
color: Colors.white,
buildIcons(
() => DeviceApps.openApp(messagesPackageName),
Icon(
Icons.message,
color: Colors.white,
),
),
),
buildIcons(
() => AppSettings.openAppSettings(),
Icon(
Icons.settings,
color: Colors.white,
buildIcons(
() => DeviceApps.openApp(cameraPackageName),
Icon(
Icons.camera,
color: Colors.white,
),
),
),
],
buildIcons(
() => DeviceApps.openApp(settingsPackageName),
Icon(
Icons.settings,
color: Colors.white,
),
),
],
),
),
),
body: Container(
key: scaffoldKey,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/wallpaper.jpg"),
fit: BoxFit.cover)),
image: AssetImage((apps == null)
? "assets/images/ubuntu-splash-screen.gif"
: "assets/images/wallpaper.jpg"),
fit: BoxFit.cover,
)),
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Row(
Expand Down
Loading

0 comments on commit bf4b7b4

Please sign in to comment.