From d90e3ce66e3cf1966cc1d60cb84318f474b389e6 Mon Sep 17 00:00:00 2001 From: stephenrichter Date: Thu, 13 Apr 2023 14:11:21 -0700 Subject: [PATCH 01/10] [#1] Add optional border radius to button --- example/lib/main.dart | 2 ++ lib/pushable_button.dart | 24 ++++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index a4dbfee..f393fe5 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -50,6 +50,7 @@ class _MyHomePageState extends State { elevation: 8, hslColor: HSLColor.fromAHSL(1.0, 356, 1.0, 0.43), shadow: shadow, + borderRadius: 4, onPressed: () => setState(() => _selection = '1'), ), SizedBox(height: 32), @@ -59,6 +60,7 @@ class _MyHomePageState extends State { elevation: 8, hslColor: HSLColor.fromAHSL(1.0, 120, 1.0, 0.37), shadow: shadow, + borderRadius: 16, onPressed: () => setState(() => _selection = '2'), ), SizedBox(height: 32), diff --git a/lib/pushable_button.dart b/lib/pushable_button.dart index 09dd8c6..4c0f9b6 100644 --- a/lib/pushable_button.dart +++ b/lib/pushable_button.dart @@ -13,6 +13,7 @@ class PushableButton extends StatefulWidget { required this.height, this.elevation = 8.0, this.shadow, + this.borderRadius, this.onPressed, }) : assert(height > 0), super(key: key); @@ -34,6 +35,10 @@ class PushableButton extends StatefulWidget { /// This is added to the bottom layer only final BoxShadow? shadow; + /// An optional border radius of the button corners + /// If no border radius is provided, the button will use [StadiumBorder] + final double? borderRadius; + /// button pressed callback final VoidCallback? onPressed; @@ -137,8 +142,9 @@ class _PushableButtonState extends AnimationControllerState { color: bottomHslColor.toColor(), boxShadow: widget.shadow != null ? [widget.shadow!] : [], - borderRadius: - BorderRadius.circular(widget.height / 2), + borderRadius: widget.borderRadius != null + ? BorderRadius.circular(widget.borderRadius!) + : BorderRadius.circular(widget.height / 2), ), ), ), @@ -149,10 +155,16 @@ class _PushableButtonState extends AnimationControllerState { top: top, child: Container( height: widget.height, - decoration: ShapeDecoration( - color: hslColor.toColor(), - shape: StadiumBorder(), - ), + decoration: widget.borderRadius != null + ? BoxDecoration( + color: hslColor.toColor(), + borderRadius: + BorderRadius.circular(widget.borderRadius!), + ) + : ShapeDecoration( + color: hslColor.toColor(), + shape: StadiumBorder(), + ), child: Center(child: widget.child), ), ), From 1e300afb4f788e2c3cfc046f3e235bfffb5a4a39 Mon Sep 17 00:00:00 2001 From: stephenrichter Date: Thu, 13 Apr 2023 14:17:21 -0700 Subject: [PATCH 02/10] [#1] Update README to document border radius property --- CHANGELOG.md | 6 ++++++ README.md | 2 ++ pubspec.yaml | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e78eac..ab4789e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.0.3 + +Add additional property to the package: + +- **borderRadius**: an optional border radius for the button corners + ## 0.0.2 Updated GitHub media images. diff --git a/README.md b/README.md index 3bac80b..c8cb964 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ PushableButton( blurRadius: 7, offset: Offset(0, 2), ), + borderRadius: 16, onPressed: () => print('Button Pressed!'), ) ``` @@ -34,6 +35,7 @@ PushableButton( - **elevation**: elevation or "gap" between the top and bottom layer - **hslColor**: color of the top layer. `HSLColor` is used instead of `Color` so that the bottom layer is automatically calculated by reducing the luminosity - **shadow**: an optional shadow to make the button look better +- **borderRadius**: an optional border radius for the button corners - **onPressed**: button callback ### [LICENSE: MIT](LICENSE) \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 6cbfeb6..d509e6b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pushable_button description: A 3D pushable button. Ideal for important CTAs in the app. -version: 0.0.2 +version: 0.0.3 homepage: https://codewithandrea.com/ repository: https://github.com/bizz84/pushable_button From 3d185f391b73c272f7671d773d054b5bcbefa54a Mon Sep 17 00:00:00 2001 From: PhuCoderrga Date: Thu, 7 Mar 2024 13:39:34 +0700 Subject: [PATCH 03/10] add outline to widget PushableButton --- example/lib/main.dart | 6 ++++-- example/test/widget_test.dart | 2 +- lib/pushable_button.dart | 8 ++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index f393fe5..7d6e794 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -65,11 +65,13 @@ class _MyHomePageState extends State { ), SizedBox(height: 32), PushableButton( + borderRadius: 8, child: Text('ADD TO BASKET', style: textStyle), height: 60, - elevation: 8, + outline: true, + elevation: 16, hslColor: HSLColor.fromAHSL(1.0, 195, 1.0, 0.43), - shadow: shadow, + // shadow: shadow, onPressed: () => setState(() => _selection = '3'), ), SizedBox(height: 32), diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index 747db1d..6db856c 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:example/main.dart'; +import '../lib/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { diff --git a/lib/pushable_button.dart b/lib/pushable_button.dart index 4c0f9b6..194008c 100644 --- a/lib/pushable_button.dart +++ b/lib/pushable_button.dart @@ -14,6 +14,7 @@ class PushableButton extends StatefulWidget { this.elevation = 8.0, this.shadow, this.borderRadius, + this.outline = false, this.onPressed, }) : assert(height > 0), super(key: key); @@ -39,6 +40,8 @@ class PushableButton extends StatefulWidget { /// If no border radius is provided, the button will use [StadiumBorder] final double? borderRadius; + final bool outline; + /// button pressed callback final VoidCallback? onPressed; @@ -157,6 +160,11 @@ class _PushableButtonState extends AnimationControllerState { height: widget.height, decoration: widget.borderRadius != null ? BoxDecoration( + border: widget.outline + ? Border.all( + width: 1.5, + color: bottomHslColor.toColor()) + : null, color: hslColor.toColor(), borderRadius: BorderRadius.circular(widget.borderRadius!), From 625ca6509c7ab5124681217493623d2a569e7ec8 Mon Sep 17 00:00:00 2001 From: PhuCoderrga Date: Thu, 7 Mar 2024 14:07:50 +0700 Subject: [PATCH 04/10] Update README to document border property --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c8cb964..0bdddf2 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ PushableButton( blurRadius: 7, offset: Offset(0, 2), ), + outline: true, borderRadius: 16, onPressed: () => print('Button Pressed!'), ) @@ -36,6 +37,7 @@ PushableButton( - **hslColor**: color of the top layer. `HSLColor` is used instead of `Color` so that the bottom layer is automatically calculated by reducing the luminosity - **shadow**: an optional shadow to make the button look better - **borderRadius**: an optional border radius for the button corners +- **outline**: an optional border for the button corners - **onPressed**: button callback ### [LICENSE: MIT](LICENSE) \ No newline at end of file From d7630bf73b1ee3d83094e6192540b8812a6ce77b Mon Sep 17 00:00:00 2001 From: PhuCoderrga Date: Wed, 8 May 2024 10:11:22 +0700 Subject: [PATCH 05/10] fix bug spacing when using outline --- lib/pushable_button.dart | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/pushable_button.dart b/lib/pushable_button.dart index 194008c..3628d2c 100644 --- a/lib/pushable_button.dart +++ b/lib/pushable_button.dart @@ -161,9 +161,21 @@ class _PushableButtonState extends AnimationControllerState { decoration: widget.borderRadius != null ? BoxDecoration( border: widget.outline - ? Border.all( - width: 1.5, - color: bottomHslColor.toColor()) + ? Border( + right: BorderSide( + width: 1.5, + color: bottomHslColor.toColor(), + ), + left: BorderSide( + width: 1.5, + color: bottomHslColor.toColor(), + ), + top: BorderSide( + width: 1.5, + color: bottomHslColor.toColor(), + ), + bottom: BorderSide.none, + ) : null, color: hslColor.toColor(), borderRadius: From e6c16b147309d602e512a4af4e5ca91ac06980cd Mon Sep 17 00:00:00 2001 From: PhuCG Date: Wed, 14 Aug 2024 09:20:47 +0700 Subject: [PATCH 06/10] upgrade sdk --- analysis_options.yaml | 4 ++ example/.metadata | 39 +++++++++++- example/analysis_options.yaml | 28 +++++++++ example/android/.gitignore | 2 + example/android/app/build.gradle | 57 +++++++++--------- .../android/app/src/debug/AndroidManifest.xml | 6 +- .../android/app/src/main/AndroidManifest.xml | 28 +++++---- .../com/example/example/MainActivity.kt | 3 +- .../app/src/main/res/values-night/styles.xml | 4 +- .../app/src/main/res/values/styles.xml | 4 +- .../app/src/profile/AndroidManifest.xml | 6 +- example/android/build.gradle | 21 ++----- example/android/gradle.properties | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 3 +- example/android/settings.gradle | 30 ++++++--- example/ios/RunnerTests/RunnerTests.swift | 12 ++++ example/macos/RunnerTests/RunnerTests.swift | 12 ++++ example/pubspec.yaml | 2 +- example/web/favicon.png | Bin 917 -> 0 bytes example/web/icons/Icon-192.png | Bin 5292 -> 0 bytes example/web/icons/Icon-512.png | Bin 8252 -> 0 bytes example/web/index.html | 45 -------------- example/web/manifest.json | 23 ------- pubspec.yaml | 3 +- test/pushable_button_test.dart | 12 ++++ 25 files changed, 192 insertions(+), 154 deletions(-) create mode 100644 analysis_options.yaml create mode 100644 example/analysis_options.yaml create mode 100644 example/ios/RunnerTests/RunnerTests.swift create mode 100644 example/macos/RunnerTests/RunnerTests.swift delete mode 100644 example/web/favicon.png delete mode 100644 example/web/icons/Icon-192.png delete mode 100644 example/web/icons/Icon-512.png delete mode 100644 example/web/index.html delete mode 100644 example/web/manifest.json create mode 100644 test/pushable_button_test.dart diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/example/.metadata b/example/.metadata index be74985..cbf1dc0 100644 --- a/example/.metadata +++ b/example/.metadata @@ -4,7 +4,42 @@ # This file should be version controlled and should not be manually edited. version: - revision: adc687823a831bbebe28bdccfac1a628ca621513 - channel: stable + revision: "a14f74ff3a1cbd521163c5f03d68113d50af93d3" + channel: "stable" project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + - platform: android + create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + - platform: ios + create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + - platform: linux + create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + - platform: macos + create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + - platform: web + create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + - platform: windows + create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml new file mode 100644 index 0000000..0d29021 --- /dev/null +++ b/example/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/example/android/.gitignore b/example/android/.gitignore index 0a741cb..6f56801 100644 --- a/example/android/.gitignore +++ b/example/android/.gitignore @@ -9,3 +9,5 @@ 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 index 6ca2344..2a2d082 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -1,59 +1,58 @@ +plugins { + id "com.android.application" + id "kotlin-android" + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() -def localPropertiesFile = rootProject.file('local.properties') +def localPropertiesFile = rootProject.file("local.properties") if (localPropertiesFile.exists()) { - localPropertiesFile.withReader('UTF-8') { reader -> + localPropertiesFile.withReader("UTF-8") { reader -> localProperties.load(reader) } } -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') +def flutterVersionCode = localProperties.getProperty("flutter.versionCode") if (flutterVersionCode == null) { - flutterVersionCode = '1' + flutterVersionCode = "1" } -def flutterVersionName = localProperties.getProperty('flutter.versionName') +def flutterVersionName = localProperties.getProperty("flutter.versionName") if (flutterVersionName == null) { - flutterVersionName = '1.0' + flutterVersionName = "1.0" } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - android { - compileSdkVersion 30 + namespace = "com.example.example" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion - sourceSets { - main.java.srcDirs += 'src/main/kotlin' + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.example.example" - minSdkVersion 16 - targetSdkVersion 30 - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName + 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. + minSdk = flutter.minSdkVersion + targetSdk = 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 + signingConfig = signingConfigs.debug } } } flutter { - source '../..' -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + source = "../.." } diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml index c208884..399f698 100644 --- a/example/android/app/src/debug/AndroidManifest.xml +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -1,6 +1,6 @@ - - diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 34dd77e..74a78b9 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,11 +1,13 @@ - - + - - @@ -38,4 +31,15 @@ android:name="flutterEmbedding" android:value="2" /> + + + + + + + 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 index e793a00..70f8f08 100644 --- a/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt +++ b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt @@ -2,5 +2,4 @@ package com.example.example import io.flutter.embedding.android.FlutterActivity -class MainActivity: FlutterActivity() { -} +class MainActivity: FlutterActivity() diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml index 449a9f9..06952be 100644 --- a/example/android/app/src/main/res/values-night/styles.xml +++ b/example/android/app/src/main/res/values-night/styles.xml @@ -3,14 +3,14 @@