From 7e840e751f738d46e556a64aae76a7e09567649a Mon Sep 17 00:00:00 2001 From: Frederik Feichtmeier Date: Wed, 15 Nov 2023 23:26:54 +0100 Subject: [PATCH] fix: Improve android support (#404) Fixes #401 --- example/.metadata | 16 +-- example/android/.gitignore | 13 ++ example/android/app/build.gradle | 67 +++++++++ .../android/app/src/debug/AndroidManifest.xml | 7 + .../android/app/src/main/AndroidManifest.xml | 33 +++++ .../com/example/example/MainActivity.kt | 6 + .../res/drawable-v21/launch_background.xml | 12 ++ .../main/res/drawable/launch_background.xml | 12 ++ .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 544 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 442 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 721 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 1031 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 1443 bytes .../app/src/main/res/values-night/styles.xml | 18 +++ .../app/src/main/res/values/styles.xml | 18 +++ .../app/src/profile/AndroidManifest.xml | 7 + example/android/build.gradle | 31 +++++ example/android/gradle.properties | 3 + .../gradle/wrapper/gradle-wrapper.properties | 5 + example/android/settings.gradle | 20 +++ example/lib/src/home/home_page.dart | 14 +- lib/src/themes/common_themes.dart | 131 ++++++++---------- 22 files changed, 326 insertions(+), 87 deletions(-) create mode 100644 example/android/.gitignore create mode 100644 example/android/app/build.gradle create mode 100644 example/android/app/src/debug/AndroidManifest.xml create mode 100644 example/android/app/src/main/AndroidManifest.xml create mode 100644 example/android/app/src/main/kotlin/com/example/example/MainActivity.kt create mode 100644 example/android/app/src/main/res/drawable-v21/launch_background.xml create mode 100644 example/android/app/src/main/res/drawable/launch_background.xml create mode 100644 example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 example/android/app/src/main/res/values-night/styles.xml create mode 100644 example/android/app/src/main/res/values/styles.xml create mode 100644 example/android/app/src/profile/AndroidManifest.xml create mode 100644 example/android/build.gradle create mode 100644 example/android/gradle.properties create mode 100644 example/android/gradle/wrapper/gradle-wrapper.properties create mode 100644 example/android/settings.gradle diff --git a/example/.metadata b/example/.metadata index 90afe1c3..a072c7d9 100644 --- a/example/.metadata +++ b/example/.metadata @@ -1,11 +1,11 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled. +# This file should be version controlled and should not be manually edited. version: - revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 - channel: stable + revision: "d211f42860350d914a5ad8102f9ec32764dc6d06" + channel: "stable" project_type: app @@ -13,11 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 - base_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 - - platform: linux - create_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 - base_revision: d3d8effc686d73e0114d71abdcccef63fa1f25d2 + create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + - platform: android + create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 # User provided section diff --git a/example/android/.gitignore b/example/android/.gitignore new file mode 100644 index 00000000..6f568019 --- /dev/null +++ b/example/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle new file mode 100644 index 00000000..118ee1d9 --- /dev/null +++ b/example/android/app/build.gradle @@ -0,0 +1,67 @@ +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()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +android { + namespace "com.example.example" + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.example.example" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies {} diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 00000000..399f6981 --- /dev/null +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..19b862ec --- /dev/null +++ b/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt new file mode 100644 index 00000000..e793a000 --- /dev/null +++ b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt @@ -0,0 +1,6 @@ +package com.example.example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/example/android/app/src/main/res/drawable-v21/launch_background.xml b/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 00000000..f74085f3 --- /dev/null +++ b/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/example/android/app/src/main/res/drawable/launch_background.xml b/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 00000000..304732f8 --- /dev/null +++ b/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAj~WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8bpbvhu0Wd6uZuB!w&u2PAxD2eNXD>P5D~Wn-+_Wa#27Xc zC?Zj|6r#X(-D3u$NCt}(Ms06KgJ4FxJVv{GM)!I~&n8Bnc94O7-Hd)cjDZswgC;Qs zO=b+9!WcT8F?0rF7!Uys2bs@gozCP?z~o%U|N3vA*22NaGQG zlg@K`O_XuxvZ&Ks^m&R!`&1=spLvfx7oGDKDwpwW`#iqdw@AL`7MR}m`rwr|mZgU`8P7SBkL78fFf!WnuYWm$5Z0 zNXhDbCv&49sM544K|?c)WrFfiZvCi9h0O)B3Pgg&ebxsLQ05GG~ AQ2+n{ literal 0 HcmV?d00001 diff --git a/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xx&nMcT!A!W`0S9QKQy;}1Cl^CgaH=;G9cpY;r$Q>i*pfB zP2drbID<_#qf;rPZx^FqH)F_D#*k@@q03KywUtLX8Ua?`H+NMzkczFPK3lFz@i_kW%1NOn0|D2I9n9wzH8m|-tHjsw|9>@K=iMBhxvkv6m8Y-l zytQ?X=U+MF$@3 zt`~i=@j|6y)RWMK--}M|=T`o&^Ni>IoWKHEbBXz7?A@mgWoL>!*SXo`SZH-*HSdS+ yn*9;$7;m`l>wYBC5bq;=U}IMqLzqbYCidGC!)_gkIk_C@Uy!y&wkt5C($~2D>~)O*cj@FGjOCM)M>_ixfudOh)?xMu#Fs z#}Y=@YDTwOM)x{K_j*Q;dPdJ?Mz0n|pLRx{4n|)f>SXlmV)XB04CrSJn#dS5nK2lM zrZ9#~WelCp7&e13Y$jvaEXHskn$2V!!DN-nWS__6T*l;H&Fopn?A6HZ-6WRLFP=R` zqG+CE#d4|IbyAI+rJJ`&x9*T`+a=p|0O(+s{UBcyZdkhj=yS1>AirP+0R;mf2uMgM zC}@~JfByORAh4SyRgi&!(cja>F(l*O+nd+@4m$|6K6KDn_&uvCpV23&>G9HJp{xgg zoq1^2_p9@|WEo z*X_Uko@K)qYYv~>43eQGMdbiGbo>E~Q& zrYBH{QP^@Sti!`2)uG{irBBq@y*$B zi#&(U-*=fp74j)RyIw49+0MRPMRU)+a2r*PJ$L5roHt2$UjExCTZSbq%V!HeS7J$N zdG@vOZB4v_lF7Plrx+hxo7(fCV&}fHq)$ literal 0 HcmV?d00001 diff --git a/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c GIT binary patch literal 1031 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q8Ax83A=Cw=BuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFa`(sgt!6~Yi|1%a`XoT0ojZ}lNrNjb9xjc(B0U1_% zz5^97Xt*%oq$rQy4?0GKNfJ44uvxI)gC`h-NZ|&0-7(qS@?b!5r36oQ}zyZrNO3 zMO=Or+<~>+A&uN&E!^Sl+>xE!QC-|oJv`ApDhqC^EWD|@=#J`=d#Xzxs4ah}w&Jnc z$|q_opQ^2TrnVZ0o~wh<3t%W&flvYGe#$xqda2bR_R zvPYgMcHgjZ5nSA^lJr%;<&0do;O^tDDh~=pIxA#coaCY>&N%M2^tq^U%3DB@ynvKo}b?yu-bFc-u0JHzced$sg7S3zqI(2 z#Km{dPr7I=pQ5>FuK#)QwK?Y`E`B?nP+}U)I#c1+FM*1kNvWG|a(TpksZQ3B@sD~b zpQ2)*V*TdwjFOtHvV|;OsiDqHi=6%)o4b!)x$)%9pGTsE z-JL={-Ffv+T87W(Xpooq<`r*VzWQcgBN$$`u}f>-ZQI1BB8ykN*=e4rIsJx9>z}*o zo~|9I;xof literal 0 HcmV?d00001 diff --git a/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 GIT binary patch literal 1443 zcmb`G{WsKk6vsdJTdFg%tJav9_E4vzrOaqkWF|A724Nly!y+?N9`YV6wZ}5(X(D_N(?!*n3`|_r0Hc?=PQw&*vnU?QTFY zB_MsH|!j$PP;I}?dppoE_gA(4uc!jV&0!l7_;&p2^pxNo>PEcNJv za5_RT$o2Mf!<+r?&EbHH6nMoTsDOa;mN(wv8RNsHpG)`^ymG-S5By8=l9iVXzN_eG%Xg2@Xeq76tTZ*dGh~Lo9vl;Zfs+W#BydUw zCkZ$o1LqWQO$FC9aKlLl*7x9^0q%0}$OMlp@Kk_jHXOjofdePND+j!A{q!8~Jn+s3 z?~~w@4?egS02}8NuulUA=L~QQfm;MzCGd)XhiftT;+zFO&JVyp2mBww?;QByS_1w! zrQlx%{^cMj0|Bo1FjwY@Q8?Hx0cIPF*@-ZRFpPc#bBw{5@tD(5%sClzIfl8WU~V#u zm5Q;_F!wa$BSpqhN>W@2De?TKWR*!ujY;Yylk_X5#~V!L*Gw~;$%4Q8~Mad z@`-kG?yb$a9cHIApZDVZ^U6Xkp<*4rU82O7%}0jjHlK{id@?-wpN*fCHXyXh(bLt* zPc}H-x0e4E&nQ>y%B-(EL=9}RyC%MyX=upHuFhAk&MLbsF0LP-q`XnH78@fT+pKPW zu72MW`|?8ht^tz$iC}ZwLp4tB;Q49K!QCF3@!iB1qOI=?w z7In!}F~ij(18UYUjnbmC!qKhPo%24?8U1x{7o(+?^Zu0Hx81|FuS?bJ0jgBhEMzf< zCgUq7r2OCB(`XkKcN-TL>u5y#dD6D!)5W?`O5)V^>jb)P)GBdy%t$uUMpf$SNV31$ zb||OojAbvMP?T@$h_ZiFLFVHDmbyMhJF|-_)HX3%m=CDI+ID$0^C>kzxprBW)hw(v zr!Gmda);ICoQyhV_oP5+C%?jcG8v+D@9f?Dk*!BxY}dazmrT@64UrP3hlslANK)bq z$67n83eh}OeW&SV@HG95P|bjfqJ7gw$e+`Hxo!4cx`jdK1bJ>YDSpGKLPZ^1cv$ek zIB?0S<#tX?SJCLWdMd{-ME?$hc7A$zBOdIJ)4!KcAwb=VMov)nK;9z>x~rfT1>dS+ zZ6#`2v@`jgbqq)P22H)Tx2CpmM^o1$B+xT6`(v%5xJ(?j#>Q$+rx_R|7TzDZe{J6q zG1*EcU%tE?!kO%^M;3aM6JN*LAKUVb^xz8-Pxo#jR5(-KBeLJvA@-gxNHx0M-ZJLl z;#JwQoh~9V?`UVo#}{6ka@II>++D@%KqGpMdlQ}?9E*wFcf5(#XQnP$Dk5~%iX^>f z%$y;?M0BLp{O3a(-4A?ewryHrrD%cx#Q^%KY1H zNre$ve+vceSLZcNY4U(RBX&)oZn*Py()h)XkE?PL$!bNb{N5FVI2Y%LKEm%yvpyTP z(1P?z~7YxD~Rf<(a@_y` literal 0 HcmV?d00001 diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 00000000..06952be7 --- /dev/null +++ b/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 00000000..cb1ef880 --- /dev/null +++ b/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 00000000..399f6981 --- /dev/null +++ b/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/example/android/build.gradle b/example/android/build.gradle new file mode 100644 index 00000000..f7eb7f63 --- /dev/null +++ b/example/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + ext.kotlin_version = '1.7.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.3.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +tasks.register("clean", Delete) { + delete rootProject.buildDir +} diff --git a/example/android/gradle.properties b/example/android/gradle.properties new file mode 100644 index 00000000..94adc3a3 --- /dev/null +++ b/example/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..3c472b99 --- /dev/null +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle new file mode 100644 index 00000000..55c4ca8b --- /dev/null +++ b/example/android/settings.gradle @@ -0,0 +1,20 @@ +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 + } + settings.ext.flutterSdkPath = flutterSdkPath() + + includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") + + plugins { + id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false + } +} + +include ":app" + +apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/example/lib/src/home/home_page.dart b/example/lib/src/home/home_page.dart index de6b31aa..cddbf71a 100644 --- a/example/lib/src/home/home_page.dart +++ b/example/lib/src/home/home_page.dart @@ -103,9 +103,10 @@ class HomePageState extends State { onDestinationSelected: (index) => setState(() => _selectedIndex = index), ), - const VerticalDivider( - width: 0.0, - ), + if (!isMobile) + const VerticalDivider( + width: 0.0, + ), Expanded( child: Center( child: _items.entries.elementAt(_selectedIndex).key, @@ -121,9 +122,10 @@ class HomePageState extends State { child: _items.entries.elementAt(_selectedIndex).key, ), ), - const Divider( - height: 0.0, - ), + if (!isMobile) + const Divider( + height: 0.0, + ), NavigationBar( destinations: [ for (final item in _items.entries) diff --git a/lib/src/themes/common_themes.dart b/lib/src/themes/common_themes.dart index bca14104..a582cf97 100644 --- a/lib/src/themes/common_themes.dart +++ b/lib/src/themes/common_themes.dart @@ -43,10 +43,10 @@ AppBarTheme _createAppBarTheme(ColorScheme colorScheme) { ), iconTheme: IconThemeData( color: colorScheme.onSurface, - size: isMobile ? kComfortableIconSize : kCompactIconSize, + size: kCompactIconSize, ), actionsIconTheme: IconThemeData(color: colorScheme.onSurface), - toolbarHeight: isMobile ? kComfortableAppBarHeight : kCompactAppBarHeight, + toolbarHeight: kCompactAppBarHeight, ); } @@ -115,24 +115,19 @@ InputDecorationTheme _createInputDecorationTheme(ColorScheme colorScheme) { ), borderRadius: radius, ), - isDense: isMobile ? false : true, + isDense: true, iconColor: colorScheme.onSurface, - contentPadding: isMobile - ? const EdgeInsets.all(12) - : const EdgeInsets.only(left: 12, right: 12, bottom: 9, top: 10), - helperStyle: isMobile ? null : textStyle, - hintStyle: isMobile ? null : textStyle, - labelStyle: isMobile ? null : textStyle, - suffixStyle: isMobile - ? null - : textStyle.copyWith( - color: colorScheme.onSurface.scale(lightness: -0.2), - ), - prefixStyle: isMobile - ? null - : textStyle.copyWith( - color: colorScheme.onSurface.scale(lightness: -0.2), - ), + contentPadding: + const EdgeInsets.only(left: 12, right: 12, bottom: 9, top: 10), + helperStyle: textStyle, + hintStyle: textStyle, + labelStyle: textStyle, + suffixStyle: textStyle.copyWith( + color: colorScheme.onSurface.scale(lightness: -0.2), + ), + prefixStyle: textStyle.copyWith( + color: colorScheme.onSurface.scale(lightness: -0.2), + ), ); } @@ -149,18 +144,9 @@ const _tooltipThemeData = TooltipThemeData( // Buttons -final _commonButtonStyle = ButtonStyle( - padding: isMobile - ? const MaterialStatePropertyAll( - EdgeInsets.symmetric( - horizontal: 16, - vertical: 18, - ), - ) - : const MaterialStatePropertyAll(EdgeInsets.all(16)), - iconSize: isMobile - ? const MaterialStatePropertyAll(kComfortableButtonIconSize) - : const MaterialStatePropertyAll(kCompactButtonIconSize), +const _commonButtonStyle = ButtonStyle( + padding: MaterialStatePropertyAll(EdgeInsets.all(16)), + iconSize: MaterialStatePropertyAll(kCompactButtonIconSize), ); final _buttonThemeData = ButtonThemeData( @@ -247,23 +233,15 @@ FilledButtonThemeData _createFilledButtonTheme( IconButtonThemeData _createIconButtonTheme(ColorScheme colorScheme) { return IconButtonThemeData( style: IconButton.styleFrom( - padding: isMobile ? null : EdgeInsets.zero, + padding: EdgeInsets.zero, foregroundColor: colorScheme.onSurface, highlightColor: colorScheme.onSurface.withOpacity(0.05), surfaceTintColor: colorScheme.background, - fixedSize: isMobile - ? null - : const Size(kCompactButtonHeight, kCompactButtonHeight), - minimumSize: isMobile - ? null - : const Size(kCompactButtonHeight, kCompactButtonHeight), - maximumSize: isMobile - ? null - : const Size(kCompactButtonHeight, kCompactButtonHeight), - tapTargetSize: isMobile - ? MaterialTapTargetSize.padded - : MaterialTapTargetSize.shrinkWrap, - iconSize: isMobile ? kComfortableIconSize : kCompactIconSize, + fixedSize: const Size(kCompactButtonHeight, kCompactButtonHeight), + minimumSize: const Size(kCompactButtonHeight, kCompactButtonHeight), + maximumSize: const Size(kCompactButtonHeight, kCompactButtonHeight), + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + iconSize: kCompactIconSize, ), ); } @@ -277,16 +255,16 @@ MenuButtonThemeData _createMenuItemTheme( tapTargetSize: MaterialTapTargetSize.shrinkWrap, alignment: Alignment.center, textStyle: MaterialStatePropertyAll(textTheme.bodyMedium), - maximumSize: MaterialStatePropertyAll( + maximumSize: const MaterialStatePropertyAll( Size( 999, - (isMobile ? kComfortableButtonHeight : kCompactButtonHeight) + 10, + (kCompactButtonHeight) + 10, ), ), - minimumSize: MaterialStatePropertyAll( + minimumSize: const MaterialStatePropertyAll( Size( 20, - (isMobile ? kComfortableButtonHeight : kCompactButtonHeight) + 10, + (kCompactButtonHeight) + 10, ), ), ), @@ -295,19 +273,12 @@ MenuButtonThemeData _createMenuItemTheme( ToggleButtonsThemeData _createToggleButtonsTheme(ColorScheme colorScheme) { return ToggleButtonsThemeData( - constraints: isMobile - ? const BoxConstraints( - minHeight: kComfortableButtonHeight, - minWidth: 60, - maxWidth: double.infinity, - maxHeight: kComfortableButtonHeight, - ) - : const BoxConstraints( - minHeight: kCompactButtonHeight, - minWidth: 50, - maxWidth: double.infinity, - maxHeight: kCompactButtonHeight, - ), + constraints: const BoxConstraints( + minHeight: kCompactButtonHeight, + minWidth: 50, + maxWidth: double.infinity, + maxHeight: kCompactButtonHeight, + ), borderRadius: const BorderRadius.all(Radius.circular(kButtonRadius)), borderColor: colorScheme.isHighContrast ? colorScheme.outlineVariant @@ -563,9 +534,9 @@ MenuThemeData _createMenuTheme(ColorScheme colorScheme) { DropdownMenuThemeData _createDropdownMenuTheme(ColorScheme colorScheme) { return DropdownMenuThemeData( inputDecorationTheme: _createInputDecorationTheme(colorScheme).copyWith( - constraints: BoxConstraints( - maxHeight: isMobile ? kComfortableButtonHeight : kCompactButtonHeight, - minHeight: isMobile ? kComfortableButtonHeight : kCompactButtonHeight, + constraints: const BoxConstraints( + maxHeight: kCompactButtonHeight, + minHeight: kCompactButtonHeight, ), ), menuStyle: _createMenuStyle(colorScheme), @@ -574,9 +545,7 @@ DropdownMenuThemeData _createDropdownMenuTheme(ColorScheme colorScheme) { NavigationBarThemeData _createNavigationBarTheme(ColorScheme colorScheme) { return NavigationBarThemeData( - height: isMobile - ? kComfortableNavigationBarHeight - : kCompactNavigationBarHeight, + height: kCompactNavigationBarHeight, backgroundColor: colorScheme.surface, surfaceTintColor: colorScheme.surface, indicatorColor: colorScheme.onSurface.withOpacity(0.1), @@ -594,11 +563,11 @@ NavigationRailThemeData _createNavigationRailTheme(ColorScheme colorScheme) { indicatorColor: colorScheme.onSurface.withOpacity(0.1), selectedIconTheme: IconThemeData( color: colorScheme.onSurface, - size: isMobile ? kComfortableIconSize : kCompactIconSize, + size: kCompactIconSize, ), unselectedIconTheme: IconThemeData( color: colorScheme.onSurface.withOpacity(0.8), - size: isMobile ? kComfortableIconSize : kCompactIconSize, + size: kCompactIconSize, ), ); } @@ -633,7 +602,7 @@ SnackBarThemeData _createSnackBarTheme(ColorScheme colorScheme) { elevation: 0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular( - isMobile ? kComfortableButtonHeight : kCompactButtonHeight, + kCompactButtonHeight, ), ), ); @@ -660,13 +629,29 @@ ThemeData createYaruTheme({ ? colorScheme.outlineVariant : colorScheme.outline; final textTheme = createTextTheme(colorScheme.onSurface); + + if (isMobile) { + return ThemeData( + textTheme: textTheme, + dividerColor: dividerColor, + scaffoldBackgroundColor: colorScheme.surface, + dividerTheme: DividerThemeData( + color: dividerColor, + space: 1.0, + thickness: 1.0, + ), + useMaterial3: true, + colorScheme: colorScheme, + ); + } + return ThemeData.from( useMaterial3: useMaterial3, colorScheme: colorScheme, ).copyWith( iconTheme: IconThemeData( color: colorScheme.onSurface, - size: isMobile ? kComfortableIconSize : kCompactIconSize, + size: kCompactIconSize, ), primaryIconTheme: IconThemeData(color: colorScheme.onSurface), progressIndicatorTheme: _createProgressIndicatorTheme(colorScheme), @@ -727,7 +712,7 @@ ThemeData createYaruTheme({ mainAxisMargin: 3.0, crossAxisMargin: 3.0, ), - splashFactory: isMobile ? null : NoSplash.splashFactory, + splashFactory: NoSplash.splashFactory, sliderTheme: _createSliderTheme(colorScheme), drawerTheme: _createDrawerTheme(colorScheme), listTileTheme: ListTileThemeData(