Skip to content

Commit

Permalink
Paid apps Improvements and fixes (#1519)
Browse files Browse the repository at this point in the history
- [x] Make install/uninstall skeleton grey
- [x] Update app logic fix
- [x] Move app pricing below description
- [x] Allow app owners to install their won paid apps without paying
- [x] Minor padding fixes for app list item
  • Loading branch information
beastoin authored Dec 10, 2024
2 parents e96e86b + ac087b0 commit 2f0e664
Show file tree
Hide file tree
Showing 6 changed files with 353 additions and 321 deletions.
93 changes: 56 additions & 37 deletions app/lib/pages/apps/app_detail/app_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -361,46 +361,63 @@ class _AppDetailPageState extends State<AppDetailPage> {
],
),
const SizedBox(height: 24),
app.enabled
isLoading
? Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: AnimatedLoadingButton(
text: 'Uninstall App',
text: '',
width: MediaQuery.of(context).size.width * 0.9,
onPressed: () => _toggleApp(app.id, false),
color: Colors.red,
onPressed: () async {},
color: Colors.grey.shade800,
),
),
)
: (app.isPaid && !app.isUserPaid
: app.enabled
? Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: AnimatedLoadingButton(
text: 'Uninstall App',
width: MediaQuery.of(context).size.width * 0.9,
text: app.getFormattedPrice(),
onPressed: () async {
if (app.paymentLink != null && app.paymentLink!.isNotEmpty) {
_checkPaymentStatus(app.id);
await launchUrl(Uri.parse(app.paymentLink!));
}
},
color: Colors.green,
onPressed: () => _toggleApp(app.id, false),
color: Colors.red,
),
),
)
: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: AnimatedLoadingButton(
width: MediaQuery.of(context).size.width * 0.9,
text: 'Install App',
onPressed: () => _toggleApp(app.id, true),
color: Colors.green,
),
),
)),
: (app.isPaid && !app.isUserPaid
? Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: AnimatedLoadingButton(
width: MediaQuery.of(context).size.width * 0.9,
text: app.getFormattedPrice(),
onPressed: () async {
if (app.paymentLink != null &&
app.paymentLink!.isNotEmpty &&
!app.isOwner(SharedPreferencesUtil().uid)) {
_checkPaymentStatus(app.id);
await launchUrl(Uri.parse(app.paymentLink!));
} else {
await _toggleApp(app.id, true);
}
},
color: Colors.green,
),
),
)
: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: AnimatedLoadingButton(
width: MediaQuery.of(context).size.width * 0.9,
text: 'Install App',
onPressed: () => _toggleApp(app.id, true),
color: Colors.green,
),
),
)),

(app.isUnderReview() || app.private) && !app.isOwner(SharedPreferencesUtil().uid)
? Column(
children: [
Expand Down Expand Up @@ -637,19 +654,21 @@ class _AppDetailPageState extends State<AppDetailPage> {
const Spacer(),
Column(
children: [
RatingBar.builder(
initialRating: app.ratingAvg ?? 0,
minRating: 1,
ignoreGestures: true,
direction: Axis.horizontal,
allowHalfRating: true,
itemCount: 5,
itemSize: 20,
tapOnlyMode: false,
itemPadding: const EdgeInsets.symmetric(horizontal: 0),
itemBuilder: (context, _) => const Icon(Icons.star, color: Colors.deepPurple),
maxRating: 5.0,
onRatingUpdate: (rating) {},
Skeleton.ignore(
child: RatingBar.builder(
initialRating: app.ratingAvg ?? 0,
minRating: 1,
ignoreGestures: true,
direction: Axis.horizontal,
allowHalfRating: true,
itemCount: 5,
itemSize: 20,
tapOnlyMode: false,
itemPadding: const EdgeInsets.symmetric(horizontal: 0),
itemBuilder: (context, _) => const Icon(Icons.star, color: Colors.deepPurple),
maxRating: 5.0,
onRatingUpdate: (rating) {},
),
),
const SizedBox(height: 4),
Text(app.ratingCount <= 0 ? "no ratings" : "${app.ratingCount}+ ratings"),
Expand Down
2 changes: 1 addition & 1 deletion app/lib/pages/apps/list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class AppListItem extends StatelessWidget {
: Container(),
app.isPaid
? Padding(
padding: const EdgeInsets.only(top: 4.0),
padding: const EdgeInsets.only(top: 8),
child: Text(
app.getFormattedPrice(),
style: TextStyle(color: Colors.grey.shade400, fontSize: 14),
Expand Down
8 changes: 7 additions & 1 deletion app/lib/pages/apps/providers/add_app_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class AddAppProvider extends ChangeNotifier {
GlobalKey<FormState> metadataKey = GlobalKey<FormState>();
GlobalKey<FormState> externalIntegrationKey = GlobalKey<FormState>();
GlobalKey<FormState> promptKey = GlobalKey<FormState>();
GlobalKey<FormState> pricingKey = GlobalKey<FormState>();

TextEditingController appNameController = TextEditingController();
TextEditingController appDescriptionController = TextEditingController();
Expand Down Expand Up @@ -302,7 +303,7 @@ class AddAppProvider extends ChangeNotifier {
}
}
if (isPaid) {
isValid = priceController.text.isNotEmpty && selectePaymentPlan != null;
isValid = formKey.currentState!.validate() && selectePaymentPlan != null;
}
return isValid;
} else {
Expand Down Expand Up @@ -330,6 +331,11 @@ class AddAppProvider extends ChangeNotifier {
return false;
}
}
if (pricingKey.currentState != null) {
if (!pricingKey.currentState!.validate()) {
return false;
}
}
if (selectedCapabilities.length == 1 && selectedCapabilities.first.id == 'proactive_notification') {
if (selectedScopes.isEmpty) {
AppSnackbar.showSnackbarError('Please select one more core capability for your app to proceed');
Expand Down
Loading

0 comments on commit 2f0e664

Please sign in to comment.