Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct navigation pop on android #98

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 33
compileSdkVersion 34
ndkVersion flutter.ndkVersion

compileOptions {
Expand Down
3 changes: 2 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<application
android:label="Koel"
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true">
android:usesCleartextTraffic="true"
android:enableOnBackInvokedCallback="true">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
121 changes: 56 additions & 65 deletions lib/ui/screens/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import 'package:app/ui/widgets/widgets.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';

class MainScreen extends StatefulWidget {
Expand Down Expand Up @@ -61,76 +60,68 @@ class _MainScreenState extends State<MainScreen> {
),
);
}

@override
Widget build(BuildContext context) {
return WillPopScope(
child: Scaffold(
body: _isOffline
? Stack(
return Scaffold(
body: _isOffline
? Stack(
children: [
DownloadedScreen(inOfflineMode: true),
Positioned(
bottom: 0,
width: MediaQuery.of(context).size.width,
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
DownloadedScreen(inOfflineMode: true),
Positioned(
bottom: 0,
width: MediaQuery.of(context).size.width,
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
const MiniPlayer(),
const ConnectivityInfoBox(),
],
),
),
),
],
)
: Stack(
children: <Widget>[
CupertinoTabScaffold(
tabBuilder: (_, index) {
return CupertinoTabView(
builder: (_) => _widgetOptions[index]);
},
tabBar: CupertinoTabBar(
backgroundColor: Colors.black12,
iconSize: 24,
activeColor: Colors.white,
height: tabBarHeight,
inactiveColor: Colors.white54,
border: Border(top: Divider.createBorderSide(context)),
items: <BottomNavigationBarItem>[
tabBarItem(
title: 'Home',
icon: CupertinoIcons.house_fill,
),
tabBarItem(
title: 'Search',
icon: CupertinoIcons.search,
),
tabBarItem(
title: 'Library',
icon: CupertinoIcons.music_albums_fill,
),
],
currentIndex: _selectedIndex,
onTap: _onItemTapped,
),
),
Positioned(
bottom:
tabBarHeight + MediaQuery.of(context).padding.bottom,
width: MediaQuery.of(context).size.width,
child: const MiniPlayer(),
),
const MiniPlayer(),
const ConnectivityInfoBox(),
],
),
),
),
],
)
: Stack(
children: <Widget>[
CupertinoTabScaffold(
tabBuilder: (_, index) {
return CupertinoTabView(
builder: (_) => _widgetOptions[index]);
},
tabBar: CupertinoTabBar(
backgroundColor: Colors.black12,
iconSize: 24,
activeColor: Colors.white,
height: tabBarHeight,
inactiveColor: Colors.white54,
border: Border(top: Divider.createBorderSide(context)),
items: <BottomNavigationBarItem>[
tabBarItem(
title: 'Home',
icon: CupertinoIcons.house_fill,
),
tabBarItem(
title: 'Search',
icon: CupertinoIcons.search,
),
tabBarItem(
title: 'Library',
icon: CupertinoIcons.music_albums_fill,
),
],
currentIndex: _selectedIndex,
onTap: _onItemTapped,
),
),
Positioned(
bottom:
tabBarHeight + MediaQuery.of(context).padding.bottom,
width: MediaQuery.of(context).size.width,
child: const MiniPlayer(),
),
],
),
onWillPop: () async {
if (!Platform.isAndroid || Navigator.of(context).canPop()) return true;
MethodChannel('dev.koel.app').invokeMethod('minimize');
return false;
},
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import Foundation

import audio_service
import audio_session
import connectivity_plus_macos
import connectivity_plus
import just_audio
import path_provider_foundation
import sqflite

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioServicePlugin.register(with: registry.registrar(forPlugin: "AudioServicePlugin"))
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin"))
JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
Expand Down
Loading