diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index ddeebe6..dd91fc6 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -26,7 +26,16 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 28 + compileSdkVersion 32 + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -40,7 +49,7 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.example" minSdkVersion 16 - targetSdkVersion 28 + targetSdkVersion 32 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -61,7 +70,4 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' } diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 90f2efc..86fb2de 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -13,27 +13,37 @@ additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> + - + + android:name="io.flutter.embedding.android.NormalTheme" + android:resource="@style/NormalTheme" + /> + + + + 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 39f4ea3..19b9762 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 @@ -1,13 +1,7 @@ package com.example.example -import android.os.Bundle - import io.flutter.app.FlutterActivity -import io.flutter.plugins.GeneratedPluginRegistrant class MainActivity(): FlutterActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - GeneratedPluginRegistrant.registerWith(this) - } + } diff --git a/example/android/build.gradle b/example/android/build.gradle index 232bc0d..20411f5 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '1.7.10' repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.3' + classpath 'com.android.tools.build:gradle:7.2.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -14,7 +14,7 @@ buildscript { allprojects { repositories { google() - jcenter() + mavenCentral() } } diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index d0d39fb..a6d608a 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 9367d48..8d4492f 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 8.0 + 9.0 diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index 55c7ece..cafc209 100755 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -1,14 +1,14 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/Users/bluemix/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/bluemix/flutter-projects/gradient_widgets/example" -export "FLUTTER_TARGET=/Users/bluemix/flutter-projects/gradient_widgets/example/lib/main.dart" +export "FLUTTER_ROOT=/Users/marsad/tools/flutter" +export "FLUTTER_APPLICATION_PATH=/Users/marsad/Marsad/Flutter_Libraries/Gradient-Widgets/example" +export "COCOAPODS_PARALLEL_CODE_SIGN=true" +export "FLUTTER_TARGET=/Users/marsad/Marsad/Flutter_Libraries/Gradient-Widgets/example/lib/main.dart" export "FLUTTER_BUILD_DIR=build" -export "SYMROOT=${SOURCE_ROOT}/../build/ios" export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NUMBER=1" -export "DART_DEFINES=flutter.inspector.structuredErrors%3Dtrue" +export "DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==" export "DART_OBFUSCATION=false" export "TRACK_WIDGET_CREATION=true" export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=/Users/bluemix/flutter-projects/gradient_widgets/example/.dart_tool/package_config.json" +export "PACKAGE_CONFIG=/Users/marsad/Marsad/Flutter_Libraries/Gradient-Widgets/example/.dart_tool/package_config.json" diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 9fc6004..98a0a31 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 50; objects = { /* Begin PBXBuildFile section */ @@ -136,7 +136,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0910; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = "The Chromium Authors"; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -286,7 +286,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -333,7 +333,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 1263ac8..1c19f4b 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + diff --git a/example/lib/main.dart b/example/lib/main.dart index b37dd5c..42abae6 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -39,13 +39,13 @@ class MyApp extends StatelessWidget { theme: ThemeData( primarySwatch: Colors.blue, ), - home: MyHomePage(title: 'Gradient Widgets'), + home: const MyHomePage(title: 'Gradient Widgets'), ); } } class MyHomePage extends StatefulWidget { - MyHomePage({Key? key, this.title}) : super(key: key); + const MyHomePage({Key? key, this.title}) : super(key: key); final String? title; @@ -63,7 +63,8 @@ class _MyHomePageState extends State { padding: const EdgeInsets.all(8), child: Text( title, - style: const TextStyle(color: Colors.black87, fontWeight: FontWeight.w200), + style: const TextStyle( + color: Colors.black87, fontWeight: FontWeight.w200), ), ), Expanded( @@ -84,15 +85,25 @@ class _MyHomePageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - brightness: Brightness.light, - backgroundColor: Colors.transparent, - centerTitle: true, - elevation: 0, + // appBar: AppBar( + // // brightness: Brightness.light, + // systemOverlayStyle: SystemUiOverlayStyle.dark, + // backgroundColor: Colors.transparent, + // centerTitle: true, + // elevation: 0, + // title: Text( + // widget.title!, + // style: const TextStyle( + // color: Colors.grey, fontWeight: FontWeight.w300), + // ), + // ), + appBar: GradientAppbar( title: Text( widget.title!, - style: TextStyle(color: Colors.grey, fontWeight: FontWeight.w300), ), + // systemOverlayStyle: SystemUiOverlayStyle.light, + elevation: 0, + centerTitle: true, ), backgroundColor: Colors.white, body: ListView( @@ -132,10 +143,12 @@ class _MyHomePageState extends State { child: GradientButton( key: Key(namedGradient.name), child: const Text('Gradient'), - callback: () => print('${namedGradient.name} clicked'), + callback: () => + print('${namedGradient.name} clicked'), increaseWidthBy: 20, gradient: namedGradient.gradient, - shadowColor: namedGradient.gradient.colors.last.withOpacity(0.25), + shadowColor: namedGradient.gradient.colors.last + .withOpacity(0.25), ), )) .toList(), @@ -151,10 +164,12 @@ class _MyHomePageState extends State { padding: const EdgeInsets.all(8), child: CircularGradientButton( key: Key('Circular ${namedGradient.name}'), - child: Icon(Icons.gradient), - callback: () => print('${namedGradient.name} clicked'), + child: const Icon(Icons.gradient), + callback: () => + print('${namedGradient.name} clicked'), gradient: namedGradient.gradient, - shadowColor: namedGradient.gradient.colors.last.withOpacity(0.5), + shadowColor: namedGradient.gradient.colors.last + .withOpacity(0.5), elevation: 5, ), )) @@ -175,7 +190,8 @@ class _MyHomePageState extends State { .take(1) .where((gradient) => gradient.gradient.colors.length == 2) .map((namedGradient) => Padding( - padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0), + padding: const EdgeInsets.symmetric( + horizontal: 0, vertical: 0), child: _divider(' Determinate', child: GradientProgressIndicator( gradient: namedGradient.gradient, @@ -199,7 +215,8 @@ class _MyHomePageState extends State { ), const Text( 'Indeterminate', - style: const TextStyle(color: Colors.black87, fontWeight: FontWeight.w200), + style: TextStyle( + color: Colors.black87, fontWeight: FontWeight.w200), ), ], ), @@ -210,9 +227,10 @@ class _MyHomePageState extends State { radius: 116, value: 70, ), - Text( + const Text( 'Determinate', - style: const TextStyle(color: Colors.black87, fontWeight: FontWeight.w200), + style: TextStyle( + color: Colors.black87, fontWeight: FontWeight.w200), ), ], ), @@ -223,7 +241,7 @@ class _MyHomePageState extends State { SizedBox( height: 65 * (gradients.length / 3), child: GridView.count( - physics: ScrollPhysics(), + physics: const ScrollPhysics(), childAspectRatio: 0.7, crossAxisCount: 5, crossAxisSpacing: 2, @@ -241,8 +259,13 @@ class _MyHomePageState extends State { child: GradientCard( gradient: gradients[index].gradient, elevation: 8, - shadowColor: gradients[index].gradient.colors.last.withOpacity(0.25), - margin: const EdgeInsets.symmetric(vertical: 2, horizontal: 2), + shadowColor: gradients[index] + .gradient + .colors + .last + .withOpacity(0.25), + margin: const EdgeInsets.symmetric( + vertical: 2, horizontal: 2), ), ), Expanded( @@ -261,7 +284,7 @@ class _MyHomePageState extends State { ), ), - Divider( + const Divider( color: Colors.blueGrey, ), ], diff --git a/example/pubspec.lock b/example/pubspec.lock index a6e3da3..e28c9cb 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,35 +7,35 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "14.0.0" + version: "46.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "0.41.2" + version: "4.6.0" archive: dependency: transitive description: name: archive url: "https://pub.dartlang.org" source: hosted - version: "2.0.13" + version: "3.1.11" args: dependency: transitive description: name: args url: "https://pub.dartlang.org" source: hosted - version: "1.6.0" + version: "2.3.1" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.8.2" boolean_selector: dependency: transitive description: @@ -49,21 +49,14 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" - cli_util: - dependency: transitive - description: - name: cli_util - url: "https://pub.dartlang.org" - source: hosted - version: "0.3.0" + version: "1.3.1" clock: dependency: transitive description: @@ -77,49 +70,49 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" convert: dependency: transitive description: name: convert url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "3.0.2" coverage: dependency: transitive description: name: coverage url: "https://pub.dartlang.org" source: hosted - version: "0.15.2" + version: "1.2.0" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "3.0.1" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "1.0.5" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.0.0" + version: "6.1.2" flutter: dependency: "direct main" description: flutter @@ -135,6 +128,13 @@ packages: description: flutter source: sdk version: "0.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.3" fuchsia_remote_debug_protocol: dependency: transitive description: flutter @@ -195,14 +195,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.4" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" mime: dependency: transitive description: @@ -216,21 +223,21 @@ packages: name: node_preamble url: "https://pub.dartlang.org" source: hosted - version: "1.4.13" + version: "2.0.1" package_config: dependency: transitive description: name: package_config url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "2.1.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" pedantic: dependency: transitive description: @@ -244,7 +251,7 @@ packages: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.1.0" pool: dependency: transitive description: @@ -258,7 +265,7 @@ packages: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.0.0" + version: "4.2.4" pub_semver: dependency: transitive description: @@ -279,21 +286,21 @@ packages: name: shelf_packages_handler url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "3.0.1" shelf_static: dependency: transitive description: name: shelf_static url: "https://pub.dartlang.org" source: hosted - version: "0.2.9+2" + version: "1.0.0" shelf_web_socket: dependency: transitive description: name: shelf_web_socket url: "https://pub.dartlang.org" source: hosted - version: "0.2.4+1" + version: "1.0.2" sky_engine: dependency: transitive description: flutter @@ -319,7 +326,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -347,7 +354,7 @@ packages: name: sync_http url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.3.0" term_glyph: dependency: transitive description: @@ -361,21 +368,21 @@ packages: name: test url: "https://pub.dartlang.org" source: hosted - version: "1.16.5" + version: "1.21.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.4.9" test_core: dependency: transitive description: name: test_core url: "https://pub.dartlang.org" source: hosted - version: "0.3.15" + version: "0.4.13" typed_data: dependency: transitive description: @@ -389,14 +396,14 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.2" vm_service: dependency: transitive description: name: vm_service url: "https://pub.dartlang.org" source: hosted - version: "5.5.0" + version: "8.2.2" watcher: dependency: transitive description: @@ -410,14 +417,14 @@ packages: name: web_socket_channel url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "2.2.0" webdriver: dependency: transitive description: name: webdriver url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "3.0.0" webkit_inspection_protocol: dependency: transitive description: @@ -433,4 +440,4 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.12.0 <3.0.0" + dart: ">=2.17.6 <3.0.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 0457dba..f34ed56 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,11 +1,10 @@ name: example description: A new Flutter project. - - +publish_to: 'none' version: 1.0.0+1 environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.17.6 <3.0.0' dependencies: gradient_widgets: @@ -13,7 +12,7 @@ dependencies: flutter: sdk: flutter - cupertino_icons: ^0.1.2 + cupertino_icons: ^1.0.5 dev_dependencies: flutter_driver: diff --git a/example/test_driver/app.dart b/example/test_driver/app.dart index d8d8d20..9a40b64 100644 --- a/example/test_driver/app.dart +++ b/example/test_driver/app.dart @@ -1,10 +1,10 @@ // backend/test_drive/app_test.dart -import 'package:flutter_driver/driver_extension.dart'; import 'package:example/main.dart' as app; +import 'package:flutter_driver/driver_extension.dart'; void main() { // This line enables the extension enableFlutterDriverExtension(); // run the app app.main(); -} \ No newline at end of file +} diff --git a/example/test_driver/app_test.dart b/example/test_driver/app_test.dart index 51f1a9e..d21c24d 100644 --- a/example/test_driver/app_test.dart +++ b/example/test_driver/app_test.dart @@ -1,12 +1,12 @@ -import 'dart:async'; -import 'dart:io'; import 'package:flutter_driver/flutter_driver.dart'; import 'package:test/test.dart'; void main() { group('basic launch test', () { - final SerializableFinder firstGradientButton = find.byValueKey('Hot Linear'); - final SerializableFinder firstCircularGradientButton = find.byValueKey('Circular Hot Linear'); + final SerializableFinder firstGradientButton = + find.byValueKey('Hot Linear'); + final SerializableFinder firstCircularGradientButton = + find.byValueKey('Circular Hot Linear'); FlutterDriver? driver; @@ -19,7 +19,6 @@ void main() { }); test('tapping buttons', () async { - await driver?.runUnsynchronized(() async { // var layoutTree = await driver.getLayerTree(); // print('layoutTree.toJson(): ${layoutTree.toJson()}'); @@ -33,10 +32,6 @@ void main() { print('will tap on the first CircularGradientButton'); await driver?.tap(firstCircularGradientButton); }); - - }); - }); } - diff --git a/lib/gradient_widgets.dart b/lib/gradient_widgets.dart index 79c895e..7378227 100644 --- a/lib/gradient_widgets.dart +++ b/lib/gradient_widgets.dart @@ -1,6 +1,7 @@ library gradient_widgets; export 'src/circular_gradient_button.dart'; +export 'src/gradient_appbar.dart'; export 'src/gradient_button.dart'; export 'src/gradient_card.dart'; export 'src/gradient_circular_progress_indicator.dart'; diff --git a/lib/src/circular_gradient_button.dart b/lib/src/circular_gradient_button.dart index e40a89b..941ae85 100644 --- a/lib/src/circular_gradient_button.dart +++ b/lib/src/circular_gradient_button.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../gradient_widgets.dart'; diff --git a/lib/src/common.dart b/lib/src/common.dart index ea3b09e..3478672 100644 --- a/lib/src/common.dart +++ b/lib/src/common.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; -Widget gradientContainer(BuildContext context, Gradient? gradient, double incHeightBy, double incWidthBy, Widget child) { - final ButtonThemeData buttonTheme = ButtonTheme.of(context).copyWith(padding: const EdgeInsets.all(0.0)); +Widget gradientContainer(BuildContext context, Gradient? gradient, + double incHeightBy, double incWidthBy, Widget child) { + final ButtonThemeData buttonTheme = + ButtonTheme.of(context).copyWith(padding: const EdgeInsets.all(0.0)); return Container( height: buttonTheme.height + incHeightBy, width: buttonTheme.minWidth + incWidthBy, diff --git a/lib/src/gradient_appbar.dart b/lib/src/gradient_appbar.dart new file mode 100644 index 0000000..33d5c58 --- /dev/null +++ b/lib/src/gradient_appbar.dart @@ -0,0 +1,128 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +import '../gradient_widgets.dart'; + +class GradientAppbar extends StatelessWidget implements PreferredSizeWidget { + const GradientAppbar({ + Key? key, + this.gradient = Gradients.vision, + this.clipBehavior = Clip.none, + this.elevation, + this.shadowColor, + this.semanticContainer = true, + this.toolbarHeight = kToolbarHeight, + this.actions, + this.leading, + this.title, + this.centerTitle, + this.systemOverlayStyle, + }) : assert(elevation == null || elevation >= 0.0), + super(key: key); + + final Clip clipBehavior; + final bool semanticContainer; + final LinearGradient gradient; + final double? elevation; + final Color? shadowColor; + + ///Defines the height of the [GradientAppbar] widget. + /// + /// By default, the value of the `toolbarHeight` is [kToolbarHeight]. + final double toolbarHeight; + + ///A widget to display before the GradientAppbar's [title]. + final Widget? leading; + + ///A primary widget to display in the GradientAppbar + final Widget? title; + + ///List of widgets to display in a row after the [title] widget. + final List? actions; + + ///Set alignment of the title widget + //If `centerTitle` property is null, then [AppBarTheme.centerTitle] of [ThemeData.appBarTheme] is used. If that is also null, then value is adapted to the current [TargetPlatform]. + final bool? centerTitle; + final SystemUiOverlayStyle? systemOverlayStyle; + + @override + Widget build(BuildContext context) { + final ThemeData theme = Theme.of(context); + + return Semantics( + container: semanticContainer, + explicitChildNodes: !semanticContainer, + child: AnnotatedRegion( + value: _getOverlayStyle(theme), + child: Material( + color: Colors.transparent, + shadowColor: shadowColor ?? Colors.grey, + elevation: elevation ?? 0, + clipBehavior: clipBehavior, + child: Container( + height: toolbarHeight * 2, + decoration: BoxDecoration( + gradient: gradient, + ), + child: SafeArea( + child: Row( + children: [ + const SizedBox(width: 18), + if (leading != null) leading!, + if (_getResectiveCenterTitle(theme)) + Expanded( + child: Center( + child: _title(), + ), + ) + else + _title(), + if (actions != null && actions!.isNotEmpty) + Row( + children: actions!, + ), + ], + ), + ), + ), + ), + ), + ); + } + + SystemUiOverlayStyle _getOverlayStyle(ThemeData theme) { + return systemOverlayStyle ?? + theme.appBarTheme.systemOverlayStyle ?? + const SystemUiOverlayStyle(); + } + + bool _getResectiveCenterTitle(ThemeData theme) { + bool platformCenterTitle() { + switch (theme.platform) { + case TargetPlatform.android: + case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: + return false; + case TargetPlatform.iOS: + case TargetPlatform.macOS: + return actions == null || actions!.length < 2; + } + } + + return centerTitle ?? + theme.appBarTheme.centerTitle ?? + platformCenterTitle(); + } + + Widget _title() => DefaultTextStyle( + style: const TextStyle( + fontSize: 18, + color: Colors.white, + fontWeight: FontWeight.bold, + ), + child: title!); + + @override + Size get preferredSize => Size.fromHeight(toolbarHeight); +} diff --git a/lib/src/gradient_card.dart b/lib/src/gradient_card.dart index b32a2d6..6fdbf54 100644 --- a/lib/src/gradient_card.dart +++ b/lib/src/gradient_card.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import '../gradient_widgets.dart'; diff --git a/lib/src/gradient_circular_progress_indicator.dart b/lib/src/gradient_circular_progress_indicator.dart index dea8f3f..efcb414 100644 --- a/lib/src/gradient_circular_progress_indicator.dart +++ b/lib/src/gradient_circular_progress_indicator.dart @@ -9,9 +9,7 @@ const int _kIndeterminateCircularDuration = 1800; class GradientCircularProgressIndicator extends StatefulWidget { const GradientCircularProgressIndicator( - {this.value, - this.gradient = Gradients.hotLinear, - this.radius = 200}); + {this.value, this.gradient = Gradients.hotLinear, this.radius = 200}); final double? value; final Gradient gradient; @@ -23,7 +21,9 @@ class GradientCircularProgressIndicator extends StatefulWidget { } } -class _GradientCircularProgressIndicatorState extends State with SingleTickerProviderStateMixin { +class _GradientCircularProgressIndicatorState + extends State + with SingleTickerProviderStateMixin { late AnimationController _controller; late Animation pAnimation; List colors = []; @@ -36,7 +36,8 @@ class _GradientCircularProgressIndicatorState extends State(begin: prevValue, end: widget.value ?? 100).animate(curvedAnimation); + curvedAnimation = + CurvedAnimation(parent: _controller, curve: Curves.fastOutSlowIn); + pAnimation = Tween(begin: prevValue, end: widget.value ?? 100) + .animate(curvedAnimation); prevValue = widget.value ?? 0; _controller.forward(); @@ -65,7 +68,8 @@ class _GradientCircularProgressIndicatorState extends State(begin: prevValue, end: widget.value).animate(curvedAnimation); + pAnimation = Tween(begin: prevValue, end: widget.value) + .animate(curvedAnimation); _controller ..reset() ..forward(); @@ -134,7 +138,11 @@ class _GradientCircularProgressIndicatorState extends State void initState() { super.initState(); - assert(widget.gradient != null, 'Please set the gradient!'); assert(widget.gradient.colors.length == 2, 'gradient must have two colors only'); diff --git a/lib/src/gradient_text.dart b/lib/src/gradient_text.dart index 759382e..aa8a1c9 100644 --- a/lib/src/gradient_text.dart +++ b/lib/src/gradient_text.dart @@ -5,8 +5,8 @@ import '../gradient_widgets.dart'; class GradientText extends StatelessWidget { const GradientText( this.data, { - this.key, required this.style, + this.key, this.gradient = Gradients.hotLinear, this.shaderRect, this.textAlign, diff --git a/lib/src/gradient_widget.dart b/lib/src/gradient_widget.dart index 0337506..cbdb105 100644 --- a/lib/src/gradient_widget.dart +++ b/lib/src/gradient_widget.dart @@ -6,7 +6,7 @@ import '../gradient_widgets.dart'; class GradientWidget extends StatefulWidget { const GradientWidget( {required this.child, - this.key, + Key? key, this.gradient = Gradients.hotLinear, this.callback, this.shadowColor = Colors.black45, @@ -24,7 +24,6 @@ class GradientWidget extends StatefulWidget { this.materialTapTargetSize}) : super(key: key); - final Key? key; final Widget child; final Gradient gradient; final Color shadowColor; @@ -49,7 +48,8 @@ class GradientWidget extends StatefulWidget { } } -class GradientButtonState extends State with SingleTickerProviderStateMixin { +class GradientButtonState extends State + with SingleTickerProviderStateMixin { late Animation _opacity; late AnimationController animationController; bool isTappedUp = false; @@ -60,9 +60,11 @@ class GradientButtonState extends State with SingleTickerProvide @override void initState() { - animationController = AnimationController(duration: const Duration(milliseconds: 200), vsync: this); + animationController = AnimationController( + duration: const Duration(milliseconds: 200), vsync: this); - _opacity = CurvedAnimation(parent: animationController, curve: Curves.fastOutSlowIn); + _opacity = CurvedAnimation( + parent: animationController, curve: Curves.fastOutSlowIn); elevation = widget.elevation; animationController.addStatusListener((status) { @@ -98,10 +100,13 @@ class GradientButtonState extends State with SingleTickerProvide Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - final BorderRadius borderRadiusCopy = widget.shapeRadius ?? BorderRadius.circular(40.0); + final BorderRadius borderRadiusCopy = + widget.shapeRadius ?? BorderRadius.circular(40.0); // ShapeBorder shapeCopy = widget.shape ?? RoundedRectangleBorder(borderRadius: borderRadiusCopy); - final ShapeBorder shapeCopy = widget.shape ?? RoundedRectangleBorder(borderRadius: borderRadiusCopy); - final TextStyle textStyleCopy = widget.textStyle ?? theme.textTheme.button!.copyWith(color: Colors.white); + final ShapeBorder shapeCopy = + widget.shape ?? RoundedRectangleBorder(borderRadius: borderRadiusCopy); + final TextStyle textStyleCopy = widget.textStyle ?? + theme.textTheme.button!.copyWith(color: Colors.white); if (widget.isEnabled) { gradient = widget.gradient; @@ -118,12 +123,14 @@ class GradientButtonState extends State with SingleTickerProvide ); } - final ButtonThemeData buttonTheme = ButtonTheme.of(context).copyWith(padding: const EdgeInsets.all(0.0)); + final ButtonThemeData buttonTheme = + ButtonTheme.of(context).copyWith(padding: const EdgeInsets.all(0.0)); return GestureDetector( behavior: HitTestBehavior.opaque, onTap: callback == null ? null : widget.callback, - onTapDown: callback == null ? null : (TapDownDetails details) => tapDown(), + onTapDown: + callback == null ? null : (TapDownDetails details) => tapDown(), onTapCancel: callback == null ? null : tapUp, onTapUp: callback == null ? null : (TapUpDetails details) => tapUp(), child: Center( @@ -141,17 +148,19 @@ class GradientButtonState extends State with SingleTickerProvide textStyle: textStyleCopy, onPressed: null, constraints: widget.constraints ?? - BoxConstraints.loose( - Size(buttonTheme.minWidth + widget.increaseWidthBy, buttonTheme.height + widget.increaseHeightBy)), + BoxConstraints.loose(Size( + buttonTheme.minWidth + widget.increaseWidthBy, + buttonTheme.height + widget.increaseHeightBy)), materialTapTargetSize: MaterialTapTargetSize.padded, clipBehavior: Clip.antiAliasWithSaveLayer, child: Stack( children: [ - gradientContainer(context, gradient, widget.increaseHeightBy, widget.increaseWidthBy, widget.child), + gradientContainer(context, gradient, widget.increaseHeightBy, + widget.increaseWidthBy, widget.child), FadeTransition( opacity: _opacity, child: Container( - decoration: BoxDecoration( + decoration: const BoxDecoration( gradient: LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, diff --git a/lib/src/gradients.dart b/lib/src/gradients.dart index 36e5d95..bd5a280 100644 --- a/lib/src/gradients.dart +++ b/lib/src/gradients.dart @@ -2,70 +2,88 @@ import 'package:flutter/widgets.dart'; // taken from https://uigradients.com class Gradients { - static final AlignmentGeometry _beginAlignment = Alignment.topLeft; - static final AlignmentGeometry _endAlignment = Alignment.bottomRight; + static const AlignmentGeometry _beginAlignment = Alignment.topLeft; + static const AlignmentGeometry _endAlignment = Alignment.bottomRight; - static LinearGradient buildGradient(AlignmentGeometry begin, AlignmentGeometry end, List colors) => + static LinearGradient buildGradient( + AlignmentGeometry begin, AlignmentGeometry end, List colors) => LinearGradient(begin: begin, end: end, colors: colors); static const hotLinear = LinearGradient( - colors: [Color(0xffF55B9A), Color(0xffF9B16E)], begin: Alignment.centerLeft, end: Alignment.centerRight); + colors: [Color(0xffF55B9A), Color(0xffF9B16E)], + begin: Alignment.centerLeft, + end: Alignment.centerRight); - static LinearGradient coralCandyGradient = - buildGradient(_beginAlignment, _endAlignment, const [Color(0xffFFF0D1), Color(0xffFFB8C6)]); + static LinearGradient coralCandyGradient = buildGradient(_beginAlignment, + _endAlignment, const [Color(0xffFFF0D1), Color(0xffFFB8C6)]); - static LinearGradient serve = - buildGradient(_beginAlignment, _endAlignment, const [Color(0xff485563), Color(0xff485563)]); + static LinearGradient serve = buildGradient(_beginAlignment, _endAlignment, + const [Color(0xff485563), Color(0xff485563)]); - static LinearGradient ali = - buildGradient(_beginAlignment, _endAlignment, const [Color(0xffff4b1f), Color(0xff1fddff)]); + static LinearGradient ali = buildGradient(_beginAlignment, _endAlignment, + const [Color(0xffff4b1f), Color(0xff1fddff)]); - static LinearGradient aliHussien = - buildGradient(_beginAlignment, _endAlignment, const [Color(0xfff7ff00), Color(0xffdb36a4)]); + static LinearGradient aliHussien = buildGradient(_beginAlignment, + _endAlignment, const [Color(0xfff7ff00), Color(0xffdb36a4)]); - static LinearGradient backToFuture = - buildGradient(_beginAlignment, _endAlignment, const [Color(0xffC02425), Color(0xffF0CB35)]); + static LinearGradient backToFuture = buildGradient(_beginAlignment, + _endAlignment, const [Color(0xffC02425), Color(0xffF0CB35)]); - static LinearGradient tameer = - buildGradient(_beginAlignment, _endAlignment, const [Color(0xff136a8a), Color(0xff267871)]); + static LinearGradient tameer = buildGradient(_beginAlignment, _endAlignment, + const [Color(0xff136a8a), Color(0xff267871)]); - static LinearGradient rainbowBlue = - buildGradient(_beginAlignment, _endAlignment, const [Color(0xff00F260), Color(0xff0575E6)]); + static LinearGradient rainbowBlue = buildGradient(_beginAlignment, + _endAlignment, const [Color(0xff00F260), Color(0xff0575E6)]); - static LinearGradient blush = - buildGradient(_beginAlignment, _endAlignment, const [Color(0xffB24592), Color(0xffF15F79)]); + static LinearGradient blush = buildGradient(_beginAlignment, _endAlignment, + const [Color(0xffB24592), Color(0xffF15F79)]); - static LinearGradient byDesign = - buildGradient(_beginAlignment, _endAlignment, const [Color(0xff009FFF), Color(0xffec2F4B)]); + static LinearGradient byDesign = buildGradient(_beginAlignment, _endAlignment, + const [Color(0xff009FFF), Color(0xffec2F4B)]); - static LinearGradient haze = - buildGradient(_beginAlignment, _endAlignment, const [Color(0xffE8EDF4), Color(0xffF6F6F8)]); + static LinearGradient haze = buildGradient(_beginAlignment, _endAlignment, + const [Color(0xffE8EDF4), Color(0xffF6F6F8)]); - static LinearGradient jShine = - buildGradient(_beginAlignment, _endAlignment, const [Color(0xff12c2e9), Color(0xffc471ed), Color(0xfff64f59)]); + static LinearGradient jShine = buildGradient(_beginAlignment, _endAlignment, + const [Color(0xff12c2e9), Color(0xffc471ed), Color(0xfff64f59)]); - static LinearGradient hersheys = buildGradient(_beginAlignment, _endAlignment, const [ + static LinearGradient hersheys = + buildGradient(_beginAlignment, _endAlignment, const [ Color(0xfff1e130c), Color(0xff9a8478), ]); - static LinearGradient taitanum = buildGradient(_beginAlignment, _endAlignment, const [ + static LinearGradient taitanum = + buildGradient(_beginAlignment, _endAlignment, const [ Color(0xff283048), Color(0xff859398), ]); - static LinearGradient cosmicFusion = buildGradient(_beginAlignment, _endAlignment, const [ + static LinearGradient cosmicFusion = + buildGradient(_beginAlignment, _endAlignment, const [ Color(0xfffff00cc), Color(0xff333399), ]); - static LinearGradient coldLinear = buildGradient(_beginAlignment, _endAlignment, const [ + static LinearGradient coldLinear = + buildGradient(_beginAlignment, _endAlignment, const [ Color(0xfff20BDFF), Color(0xffA5FECB), ]); - static LinearGradient deepSpace = buildGradient(_beginAlignment, _endAlignment, const [ + static LinearGradient deepSpace = + buildGradient(_beginAlignment, _endAlignment, const [ Color(0xff000000), Color(0xff434343), ]); + + static const vision = LinearGradient( + colors: [Color(0xff000146), Color(0xff1DB3DF)], + begin: Alignment.centerLeft, + end: Alignment.centerRight); + + static const coal = LinearGradient( + colors: [Color(0xffEB5757), Color(0xff000000)], + begin: Alignment.centerLeft, + end: Alignment.centerRight); } diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..339983b --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,146 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.2" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.16.0" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.4" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.1" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.2" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.9" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" +sdks: + dart: ">=2.17.6 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 41cec63..ee7eb62 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.6.0 homepage: https://github.com/bluemix/gradient-widgets environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.17.6 <3.0.0' dependencies: flutter: