Skip to content

Commit

Permalink
Update App Analytics to reflect new payment system (#1686)
Browse files Browse the repository at this point in the history
closes #1671 

- [x] update app analytics widget to reflect subscription earning
- [x] add learn more option to know more details on earning
- [x] create an article regarding earning
(https://help.omi.me/en/articles/10401566-build-publish-and-earn-with-omi-apps)


https://github.com/user-attachments/assets/acc46a49-e98b-40ae-9fa1-374e2c9cf823
  • Loading branch information
beastoin authored Jan 16, 2025
2 parents 57d8f4f + 646b111 commit 4a4ce4c
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 63 deletions.
66 changes: 3 additions & 63 deletions app/lib/pages/apps/app_detail/app_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import 'package:cached_network_image/cached_network_image.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'package:flutter_svg/svg.dart';
import 'package:friend_private/backend/http/api/apps.dart';
import 'package:friend_private/backend/preferences.dart';
import 'package:friend_private/gen/assets.gen.dart';
import 'package:friend_private/pages/apps/app_detail/reviews_list_page.dart';
import 'package:friend_private/pages/apps/app_detail/widgets/add_review_widget.dart';
import 'package:friend_private/pages/apps/markdown_viewer.dart';
Expand All @@ -27,6 +25,7 @@ import 'dart:async';

import '../../../backend/schema/app.dart';
import '../widgets/show_app_options_sheet.dart';
import 'widgets/app_analytics_widget.dart';
import 'widgets/info_card_widget.dart';

import 'package:timeago/timeago.dart' as timeago;
Expand All @@ -45,8 +44,6 @@ class _AppDetailPageState extends State<AppDetailPage> {
bool setupCompleted = false;
bool appLoading = false;
bool isLoading = false;
double moneyMade = 0.0;
int usageCount = 0;
Timer? _paymentCheckTimer;
late App app;
late bool showInstallAppConfirmation;
Expand Down Expand Up @@ -76,12 +73,9 @@ class _AppDetailPageState extends State<AppDetailPage> {
setState(() {
if (res != null) {
app = res;
moneyMade = res.moneyMade ?? 0.0;
usageCount = res.usageCount ?? 0;
}
});
setIsLoading(false);

context.read<AppProvider>().checkIsAppOwner(app.uid);
context.read<AppProvider>().setIsAppPublicToggled(!app.private);
});
Expand Down Expand Up @@ -729,62 +723,8 @@ class _AppDetailPageState extends State<AppDetailPage> {
// widget.plugin.worksExternally() ? const SizedBox(height: 16) : const SizedBox.shrink(),
app.private
? const SizedBox.shrink()
: Container(
width: double.infinity,
padding: const EdgeInsets.all(16.0),
margin: const EdgeInsets.only(left: 8.0, right: 8.0, top: 12, bottom: 6),
decoration: BoxDecoration(
color: Colors.grey.shade900,
borderRadius: BorderRadius.circular(16.0),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('App Analytics', style: TextStyle(color: Colors.white, fontSize: 16)),
const SizedBox(height: 16),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Skeleton.shade(child: SvgPicture.asset(Assets.images.icChart, width: 20)),
const SizedBox(width: 8),
Text(
usageCount.toString(),
style: const TextStyle(color: Colors.white, fontSize: 30),
),
],
),
const SizedBox(height: 6),
Text('Times Used', style: TextStyle(color: Colors.grey.shade300, fontSize: 14)),
],
),
const Spacer(flex: 2),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Skeleton.shade(child: SvgPicture.asset(Assets.images.icDollar, width: 20)),
const SizedBox(width: 8),
Text(
"\$$moneyMade",
style: const TextStyle(color: Colors.white, fontSize: 28),
),
],
),
const SizedBox(height: 6),
Text('Money Earned', style: TextStyle(color: Colors.grey.shade300, fontSize: 14)),
],
),
const Spacer(flex: 2),
],
),
],
),
),
: AppAnalyticsWidget(
installs: app.installs, moneyMade: app.isPaid ? ((app.price ?? 0) * app.installs) : 0),
const SizedBox(height: 60),
],
),
Expand Down
91 changes: 91 additions & 0 deletions app/lib/pages/apps/app_detail/widgets/app_analytics_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:friend_private/gen/assets.gen.dart';
import 'package:friend_private/utils/analytics/intercom.dart';
import 'package:skeletonizer/skeletonizer.dart';

class AppAnalyticsWidget extends StatelessWidget {
final int installs;
final double moneyMade;
const AppAnalyticsWidget({super.key, required this.installs, required this.moneyMade});

@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
padding: const EdgeInsets.all(16.0),
margin: const EdgeInsets.only(left: 8.0, right: 8.0, top: 12, bottom: 6),
decoration: BoxDecoration(
color: Colors.grey.shade900,
borderRadius: BorderRadius.circular(16.0),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
const Text('App Analytics', style: TextStyle(color: Colors.white, fontSize: 16)),
const Spacer(),
GestureDetector(
onTap: () async {
await IntercomManager().displayEarnMoneyArticle();
},
child: Row(
children: [
Text("learn more", style: TextStyle(color: Colors.grey.shade400, fontSize: 14)),
Icon(
Icons.arrow_outward_rounded,
size: 12,
color: Colors.grey.shade400,
)
],
),
),
],
),
const SizedBox(height: 16),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Skeleton.shade(child: SvgPicture.asset(Assets.images.icChart, width: 20)),
const SizedBox(width: 8),
Text(
installs.toString(),
style: const TextStyle(color: Colors.white, fontSize: 30),
),
],
),
const SizedBox(height: 6),
Text('Installs', style: TextStyle(color: Colors.grey.shade300, fontSize: 14)),
],
),
const Spacer(flex: 2),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Skeleton.shade(child: SvgPicture.asset(Assets.images.icDollar, width: 20)),
const SizedBox(width: 8),
Text(
"\$$moneyMade",
style: const TextStyle(color: Colors.white, fontSize: 28),
),
],
),
const SizedBox(height: 6),
Text('Money Earned', style: TextStyle(color: Colors.grey.shade300, fontSize: 14)),
],
),
const Spacer(flex: 2),
],
),
],
),
);
}
}
4 changes: 4 additions & 0 deletions app/lib/utils/analytics/intercom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class IntercomManager {
}
}

Future displayEarnMoneyArticle() async {
return await intercom.displayArticle('10401566-build-publish-and-earn-with-omi-apps');
}

Future displayFirmwareUpdateArticle() async {
return await intercom.displayArticle('9918118-updating-your-friend-device-firmware');
}
Expand Down

0 comments on commit 4a4ce4c

Please sign in to comment.