Skip to content

Commit

Permalink
bug fix : navigate back in homescreen of launcher
Browse files Browse the repository at this point in the history
  • Loading branch information
jspw committed Nov 29, 2020
1 parent 260ddbf commit a881871
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 163 deletions.
Binary file not shown.
Binary file not shown.
151 changes: 77 additions & 74 deletions lib/UI/Screens/apps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AppsState extends State {
List<String> sortTypes = [
'Alphabetically',
'Installation Time',
'UpdateTime',
'Update Time',
];

String sortType;
Expand All @@ -43,7 +43,7 @@ class AppsState extends State {
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")
else if (sortType == "Update Time")
apps.sort((b, a) => a.updateTimeMillis.compareTo(b.updateTimeMillis));
});
}
Expand Down Expand Up @@ -95,87 +95,90 @@ class AppsState extends State {
Widget build(BuildContext context) {
// TODO: implement build
// throw UnimplementedError();
return Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
return WillPopScope(
onWillPop: () async => false,
child: Scaffold(
backgroundColor: Colors.transparent,
title: Text(
'Applications',
style: TextStyle(fontSize: 25),
),
titleSpacing: 1.2,
centerTitle: true,
leading: GestureDetector(
onTap: () => Navigator.pop(context, [apps, sortType]),
child: Container(
child: Image.asset(
"assets/images/ic_launcher.png",
fit: BoxFit.cover,
appBar: AppBar(
backgroundColor: Colors.transparent,
title: Text(
'Applications',
style: TextStyle(fontSize: 25),
),
titleSpacing: 1.2,
centerTitle: true,
leading: GestureDetector(
onTap: () => Navigator.pop(context, [apps, sortType]),
child: Container(
child: Image.asset(
"assets/images/ic_launcher.png",
fit: BoxFit.cover,
),
),
),
actions: <Widget>[
sortTypeList(),
],
),
actions: <Widget>[
sortTypeList(),
],
),
body: RefreshIndicator(
color: Colors.transparent,
onRefresh: () => appInfo(),
child: apps == null
? Center(
child: Container(
height: 50,
width: 50,
color: Colors.transparent,
child: Image.asset(
"assets/images/loader2.gif",
fit: BoxFit.cover,
body: RefreshIndicator(
color: Colors.transparent,
onRefresh: () => appInfo(),
child: apps == null
? Center(
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);
Navigator.pop(context, [apps, sortType]);
},
child: app is ApplicationWithIcon
? GridTile(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Container(
child: CircleAvatar(
backgroundImage: MemoryImage(
app.icon,
)
: 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);
Navigator.pop(context, [apps, sortType]);
},
child: app is ApplicationWithIcon
? GridTile(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[
Container(
child: CircleAvatar(
backgroundImage: MemoryImage(
app.icon,
),
backgroundColor: Colors.white,
),
backgroundColor: Colors.white,
),
),
Text(
app.appName,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
Text(
app.appName,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
overflow: TextOverflow.ellipsis,
),
overflow: TextOverflow.ellipsis,
),
],
],
),
),
),
)
: null);
}),
),
)
: null);
}),
),
),
),
);
}
Expand Down
179 changes: 91 additions & 88 deletions lib/UI/Screens/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ class HomeState extends State {
apps = data;
});

print(apps);
// print(apps);

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

String settingsPackageNameDemo;
String cameraPackageNameDemo;
Expand Down Expand Up @@ -123,99 +123,102 @@ class HomeState extends State {

@override
Widget build(BuildContext context) {
return Scaffold(
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,
return WillPopScope(
onWillPop: () async => false,
child: Scaffold(
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(
() => DeviceApps.openApp(messagesPackageName),
Icon(
Icons.message,
color: Colors.white,
buildIcons(
() => DeviceApps.openApp(messagesPackageName),
Icon(
Icons.message,
color: Colors.white,
),
),
),
buildIcons(
() => DeviceApps.openApp(cameraPackageName),
Icon(
Icons.camera,
color: Colors.white,
buildIcons(
() => DeviceApps.openApp(cameraPackageName),
Icon(
Icons.camera,
color: Colors.white,
),
),
),
buildIcons(
() => DeviceApps.openApp(settingsPackageName),
Icon(
Icons.settings,
color: Colors.white,
buildIcons(
() => DeviceApps.openApp(settingsPackageName),
Icon(
Icons.settings,
color: Colors.white,
),
),
),
],
],
),
),
),
),
body: (apps == null)
? Container(
key: scaffoldKey,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/ubuntu-splash-screen.gif"),
fit: BoxFit.cover,
)),
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
)
: Container(
key: scaffoldKey,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/wallpaper.jpg"),
fit: BoxFit.cover,
)),
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Row(
children: <Widget>[
GestureDetector(
onTap: () {
scaffoldKey.currentState.openDrawer();
},
child: Container(
color: Colors.transparent,
height: MediaQuery.of(context).size.height,
child: SizedBox(
width: 70,
)),
),
],
body: (apps == null)
? Container(
key: scaffoldKey,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/ubuntu-splash-screen.gif"),
fit: BoxFit.cover,
)),
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
)
: Container(
key: scaffoldKey,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/wallpaper.jpg"),
fit: BoxFit.cover,
)),
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Row(
children: <Widget>[
GestureDetector(
onTap: () {
scaffoldKey.currentState.openDrawer();
},
child: Container(
color: Colors.transparent,
height: MediaQuery.of(context).size.height,
child: SizedBox(
width: 70,
)),
),
],
),
),
),
drawerEnableOpenDragGesture: (apps == null) ? false : true,
drawerEnableOpenDragGesture: (apps == null) ? false : true,
),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 2.0.0+3
version: 2.0.1+4

environment:
sdk: ">=2.7.0 <3.0.0"
Expand Down

0 comments on commit a881871

Please sign in to comment.