Skip to content

Commit

Permalink
Update to material 3
Browse files Browse the repository at this point in the history
  • Loading branch information
RblSb committed Mar 18, 2024
1 parent ef6c563 commit 5090a3a
Show file tree
Hide file tree
Showing 10 changed files with 241 additions and 185 deletions.
23 changes: 8 additions & 15 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand All @@ -21,18 +22,14 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
compileSdkVersion 33
compileSdkVersion 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -51,7 +48,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.SyncTube"
minSdkVersion 19
targetSdkVersion 28
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down Expand Up @@ -80,7 +77,3 @@ android {
flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
13 changes: 0 additions & 13 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
buildscript {
ext.kotlin_version = '1.8.22'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
Expand Down
30 changes: 22 additions & 8 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.1.2" apply false
id "org.jetbrains.kotlin.android" version "1.9.23" apply false
}

include ":app"
42 changes: 27 additions & 15 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ class _AppState extends State<App> with WidgetsBindingObserver {
),
child: GestureDetector(
onTap: () => removeFocus(),
child: WillPopScope(
onWillPop: () => _onWillPop(context),
child: PopScope(
// canPop: canPop,
canPop: false,
onPopInvoked: (didPop) => _onWillPop(context),
child: Selector<AppModel, bool>(
selector: (context, app) => app.hasSystemUi,
builder: (context, hasSystemUi, _) =>
Expand Down Expand Up @@ -231,6 +233,7 @@ class _AppState extends State<App> with WidgetsBindingObserver {
SystemChrome.restoreSystemUIOverlays();
}

// var canPop = false;
Future<bool> _onWillPop(BuildContext context) async {
if (!Settings.isTV) {
if (!app.isChatVisible) {
Expand All @@ -245,19 +248,28 @@ class _AppState extends State<App> with WidgetsBindingObserver {
}
bool? dialog = await showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('Are you sure?'),
content: const Text('Do you want to exit channel?'),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(false),
child: const Text('No'),
),
TextButton(
onPressed: () => Navigator.of(context).pop(true),
child: const Text('Yes'),
),
],
builder: (context) => PopScope(
canPop: true,
child: AlertDialog(
title: const Text('Are you sure?'),
content: const Text('Do you want to exit channel?'),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop(false);
},
child: const Text('No'),
),
TextButton(
onPressed: () {
// canPop = true;
Navigator.of(context).pop(true);
Navigator.of(context).pop(true);
},
child: const Text('Yes'),
),
],
),
),
);
SystemChrome.restoreSystemUIOverlays();
Expand Down
5 changes: 5 additions & 0 deletions lib/chat_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class ChatPanel extends StatelessWidget {
const Spacer(flex: 2),
TextButton(
onPressed: () => showUsersSnackBar(context),
style: ButtonStyle(
padding: MaterialStateProperty.all(
EdgeInsets.symmetric(horizontal: 5, vertical: 5),
),
),
child: _onlineButton(panel, context),
),
const Spacer(flex: 100),
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Main extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = ThemeData.from(
useMaterial3: false,
// useMaterial3: false,
colorScheme: ColorScheme.fromSwatch(
brightness: Brightness.dark,
primarySwatch: Colors.blue,
Expand Down
158 changes: 85 additions & 73 deletions lib/playlist.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,11 @@ class Playlist extends StatelessWidget {
required int pos,
}) {
const containerPadding = EdgeInsets.all(5.0);
const paddingNum = 5.0;
const btnPadding = EdgeInsets.all(paddingNum);
final isActive = pos == playlist.pos;
final time = item.isIframe ? '' : duration(item.duration);
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
double parentWidth = constraints.maxWidth;
final iconConstraints = parentWidth > 150
? null
: BoxConstraints(
minWidth: 40,
minHeight: 50,
);
double? iconMinW = parentWidth > 150 ? null : 40;
return Container(
decoration: BoxDecoration(
color: isActive
Expand All @@ -43,90 +35,45 @@ class Playlist extends StatelessWidget {
padding: containerPadding,
child: Wrap(
children: [
GestureDetector(
onLongPress: () {
Clipboard.setData(ClipboardData(text: item.url));
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'Video URL is copied',
style: TextStyle(color: Colors.white),
),
backgroundColor: Colors.black45,
),
);
},
child: Row(
children: [
Padding(
padding: btnPadding,
child: Text(time),
),
Expanded(
child: Container(
padding: btnPadding,
child: Text(
item.title,
overflow: TextOverflow.fade,
softWrap: false,
style: const TextStyle(fontSize: 18),
),
),
),
],
),
titleLine(
context,
item: item,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
IconButton(
padding: EdgeInsets.zero,
constraints: iconConstraints,
playlistBtn(
context,
size: iconMinW,
onPressed: () => playlist.sendPlayItem(pos),
tooltip: 'Play item',
icon: Icon(
Icons.play_arrow,
size: 30,
color: Theme.of(context).icon,
),
iconData: Icons.play_arrow,
),
IconButton(
padding: EdgeInsets.zero,
constraints: iconConstraints,
playlistBtn(
context,
size: iconMinW,
onPressed: () => playlist.sendSetNextItem(pos),
tooltip: 'Set item as next',
icon: Icon(
Icons.arrow_upward,
size: 30,
color: Theme.of(context).icon,
),
iconData: Icons.arrow_upward,
),
if (parentWidth > 200)
IconButton(
padding: EdgeInsets.zero,
constraints: iconConstraints,
playlistBtn(
context,
size: iconMinW,
onPressed: () => playlist.sendToggleItemType(pos),
tooltip: 'Lock/unlock item',
icon: Icon(
item.isTemp ? Icons.lock_open : Icons.lock,
size: 30,
color: Theme.of(context).icon,
),
iconData: item.isTemp ? Icons.lock_open : Icons.lock,
),
IconButton(
padding: EdgeInsets.zero,
constraints: iconConstraints,
playlistBtn(
context,
size: iconMinW,
onPressed: () {
final item = playlist.getItem(pos);
if (item == null) return;
playlist.sendRemoveItem(item.url);
},
tooltip: 'Remove item',
icon: Icon(
Icons.clear,
size: 30,
color: Theme.of(context).icon,
),
iconData: Icons.clear,
),
],
),
Expand All @@ -136,6 +83,71 @@ class Playlist extends StatelessWidget {
});
}

Widget titleLine(
BuildContext context, {
required VideoList item,
}) {
final time = item.isIframe ? '' : duration(item.duration);
const btnPadding = EdgeInsets.all(5.0);
return GestureDetector(
onLongPress: () {
Clipboard.setData(ClipboardData(text: item.url));
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'Video URL is copied',
style: TextStyle(color: Colors.white),
),
backgroundColor: Colors.black45,
),
);
},
child: Row(
children: [
Padding(
padding: btnPadding,
child: Text(time),
),
Expanded(
child: Container(
padding: btnPadding,
child: Text(
item.title,
overflow: TextOverflow.fade,
softWrap: false,
style: const TextStyle(fontSize: 18),
),
),
),
],
),
);
}

Widget playlistBtn(
BuildContext context, {
double? size = null,
required void Function() onPressed,
required String tooltip,
required IconData iconData,
}) {
return Container(
padding: const EdgeInsets.all(0.0),
width: size,
child: IconButton(
padding: EdgeInsets.zero,
// constraints: iconConstraints,
onPressed: onPressed,
tooltip: tooltip,
icon: Icon(
iconData,
size: 30,
color: Theme.of(context).icon,
),
),
);
}

String duration(double timeNum) {
final h = timeNum / 60 ~/ 60;
final m = timeNum ~/ 60 - h * 60;
Expand Down
Loading

0 comments on commit 5090a3a

Please sign in to comment.