Skip to content
This repository has been archived by the owner on Mar 12, 2022. It is now read-only.

Commit

Permalink
Add possibility to change the stars color
Browse files Browse the repository at this point in the history
and bump version
  • Loading branch information
bdlukaa committed Jul 27, 2021
1 parent 6a1d290 commit 3d7ed13
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,7 @@ Date format: DD/MM/YYYY

- Upgrade Android SDK to version 20.2.0
- Removed `onLeftApplication` event.
- Possibility to change the RatingBar color (Fixes [#84](https://github.com/bdlukaa/native_admob_flutter/issues/84))

## [1.4.1] - [19/07/2021]

Expand Down
Expand Up @@ -7,6 +7,7 @@ import android.graphics.Typeface
import android.graphics.drawable.GradientDrawable
import android.graphics.drawable.GradientDrawable.Orientation
import android.graphics.drawable.GradientDrawable.RADIAL_GRADIENT
import android.graphics.PorterDuff
import android.os.Build
import android.text.TextUtils
import android.view.Gravity
Expand Down Expand Up @@ -97,6 +98,10 @@ class NativeAdPlatformView(context: Context, data: Map<String?, Any?>?) : Platfo
}
"rating_bar" -> {
view = RatingBar(context, null, android.R.attr.ratingBarStyleSmall)
(data["starsColor"] as? String)?.let {
val drawableReview = (view as RatingBar).progressDrawable
drawableReview.setColorFilter(Color.parseColor(it), PorterDuff.Mode.SRC_ATOP)
}
}
"button_view" -> {
view = Button(context)
Expand Down
2 changes: 2 additions & 0 deletions example/lib/screens/native_ads.dart
Expand Up @@ -168,6 +168,7 @@ class _NativeAdsState extends State<NativeAds>
height: MATCH_PARENT,
textStyle: TextStyle(color: Colors.white),
),
ratingBar: AdRatingBarView(starsColor: Colors.white),
),
SizedBox(height: 10),
NativeAd(
Expand Down Expand Up @@ -241,6 +242,7 @@ class _NativeAdsState extends State<NativeAds>
elevationColor: Colors.amber,
height: MATCH_PARENT,
),
ratingBar: AdRatingBarView(starsColor: Colors.white),
),
]),
);
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Expand Up @@ -80,7 +80,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.4.1"
version: "1.5.0"
path:
dependency: transitive
description:
Expand Down
8 changes: 7 additions & 1 deletion lib/src/native/layout_builder/layout_builder.dart
Expand Up @@ -191,6 +191,7 @@ class AdMediaView extends AdView {

class AdRatingBarView extends AdView {
final double? stepSize;
final Color? starsColor;

AdRatingBarView({
EdgeInsets? padding,
Expand All @@ -202,6 +203,7 @@ class AdRatingBarView extends AdView {
Color? elevationColor,
// rating
this.stepSize,
this.starsColor,
}) : super(
viewType: 'rating_bar',
padding: padding,
Expand All @@ -226,12 +228,16 @@ class AdRatingBarView extends AdView {
elevation: view.elevation ?? elevation,
elevationColor: view.elevationColor ?? elevationColor,
stepSize: (view as AdRatingBarView).stepSize,
starsColor: view.starsColor ?? starsColor,
);
}

Map<String, dynamic> toJson() {
final json = super.toJson();
json.addAll({'stepSize': stepSize});
json.addAll({
'stepSize': stepSize,
'starsColor': starsColor?.toHex(),
});
return json;
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
@@ -1,6 +1,6 @@
name: native_admob_flutter
description: Create native ads easily purely in dart using PlatformViews and Google's ADMOB Sdk
version: 1.4.1
version: 1.5.0
repository: https://github.com/bdlukaa/native_admob_flutter

environment:
Expand Down

0 comments on commit 3d7ed13

Please sign in to comment.