Skip to content

Commit

Permalink
feat(analytics): implement wiredash feedback form
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-the-shark committed Aug 29, 2024
1 parent bf953c3 commit 8856176
Show file tree
Hide file tree
Showing 14 changed files with 4,374 additions and 27 deletions.
4,259 changes: 4,259 additions & 0 deletions assets/animations/bug.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ targets:
envied_generator:envied:
generate_for:
include:
- lib/config/api_base_config.dart
- lib/config/env.dart
graphql_codegen:
options:
clients:
Expand Down
4 changes: 3 additions & 1 deletion example.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
API_URL="https://<...>"
ASSETS_URL="https://<...>"
IPARKING_URL="https://<...>"
IPARKING_URL="https://<...>"
WIREDASH_ID="<...>"
WIREDASH_SECRET="<...>"
4 changes: 2 additions & 2 deletions lib/api_base/directus_assets_url.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import "package:flutter/material.dart";

import "../config/api_base_config.dart";
import "../config/env.dart";

extension DirectusAssetsUrlX on String {
String get directusUrl {
if (startsWith("https://") || startsWith("http://")) {
return this; // Already a full URL (not from directus)
}
return "${ApiBaseEnv.assetsUrl}/$this";
return "${Env.assetsUrl}/$this";
}

String directusUrlWithSize(Size size, BoxFit fit) {
Expand Down
4 changes: 2 additions & 2 deletions lib/api_base/gql_client_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "package:flutter/foundation.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:graphql/client.dart";

import "../config/api_base_config.dart";
import "../config/env.dart";

final _hiveCacheBoxProvider = Provider((ref) async {
if (kIsWeb) return GraphQLCache(); // Normal in memory cache
Expand All @@ -14,7 +14,7 @@ final gqlClientProvider = Provider((ref) async {
final hiveCache = await ref.watch(_hiveCacheBoxProvider);
return GraphQLClient(
cache: hiveCache,
link: HttpLink(ApiBaseEnv.apiUrl),
link: HttpLink(Env.apiUrl),
defaultPolicies: DefaultPolicies(
query: Policies(
fetch: FetchPolicy.networkOnly,
Expand Down
2 changes: 1 addition & 1 deletion lib/api_base/ttl/local_timestamp_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "package:graphql/client.dart";
import "package:riverpod_annotation/riverpod_annotation.dart";
import "package:shared_preferences/shared_preferences.dart";

import "../../config/api_base_config.dart";
import "../../config/env.dart";
import "../../config/ttl_config.dart";
import "../../utils/timestamp.dart";
import "ttl_timestamp.dart";
Expand Down
14 changes: 9 additions & 5 deletions lib/config/api_base_config.dart → lib/config/env.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "package:envied/envied.dart";

part "api_base_config.g.dart";
part "env.g.dart";

abstract class ApiBaseConfig {
static const hiveCacheBoxName = "hiveCacheBoxForDirectusGraphQL";
Expand All @@ -14,11 +14,15 @@ abstract class ApiBaseConfig {
useConstantCase: true,
requireEnvFile: true,
)
abstract class ApiBaseEnv {
abstract class Env {
@EnviedField()
static final String apiUrl = _ApiBaseEnv.apiUrl;
static final String apiUrl = _Env.apiUrl;
@EnviedField()
static final String assetsUrl = _ApiBaseEnv.assetsUrl;
static final String assetsUrl = _Env.assetsUrl;
@EnviedField()
static final String iparkingUrl = _ApiBaseEnv.iparkingUrl;
static final String iparkingUrl = _Env.iparkingUrl;
@EnviedField()
static final String wiredashId = _Env.wiredashId;
@EnviedField()
static final String wiredashSecret = _Env.wiredashSecret;
}
42 changes: 42 additions & 0 deletions lib/features/analytics/wiredash/show_feedback_tile.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import "package:flutter/material.dart";
import "package:lottie/lottie.dart";
import "package:wiredash/wiredash.dart";

import "../../../config/ui_config.dart";
import "../../../gen/assets.gen.dart";
import "../../../utils/context_extensions.dart";
import "../../../widgets/wide_tile_card.dart";

class ShowFeedbackTile extends StatelessWidget {
const ShowFeedbackTile({super.key});

@override
Widget build(BuildContext context) {
return WideTileCard(
title: context.localize.bug_report_title,
subtitle: context.localize.bug_report_subtitle,
onTap: () {
Wiredash.of(context).show(
options: WiredashFeedbackOptions(
labels: [
Label(
id: "label-a9v91o7kdq",
title: context.localize.new_feature,
),
Label(id: "label-bekp7mkn82", title: context.localize.bug),
Label(id: "label-ykl4o5vddu", title: context.localize.praise),
],
),
);
},
trailing: Lottie.asset(
Assets.animations.bug,
width: WideTileCardConfig.imageSize,
height: WideTileCardConfig.imageSize,
animate: true,
repeat: true,
frameRate: FrameRate.max,
),
);
}
}
23 changes: 23 additions & 0 deletions lib/features/analytics/wiredash/wiredash_theme.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import "package:wiredash/wiredash.dart";

import "../../../theme/colors.dart";

abstract class WiredashTheme {
static WiredashThemeData get theme => WiredashThemeData(
primaryColor: ColorsConsts.orangePomegranade,
secondaryColor: ColorsConsts.blueAzure,
primaryBackgroundColor: ColorsConsts.whiteSoap,
secondaryBackgroundColor: ColorsConsts.whiteSoap,
appBackgroundColor: ColorsConsts.blackMirage,
appHandleBackgroundColor: ColorsConsts.greyPigeon,
firstPenColor: ColorsConsts.orangePomegranade,
secondPenColor: ColorsConsts.blueAzure,
thirdPenColor: ColorsConsts.greyPigeon,
fourthPenColor: ColorsConsts.blackMirage,
errorColor: ColorsConsts.orangePomegranade,
primaryContainerColor: ColorsConsts.blueAzure,
textOnPrimaryContainerColor: ColorsConsts.whiteSoap,
secondaryContainerColor: ColorsConsts.greyLight,
textOnSecondaryContainerColor: ColorsConsts.blackMirage,
);
}
2 changes: 2 additions & 0 deletions lib/features/guide_view/guide_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "../../config/ui_config.dart";
import "../../utils/context_extensions.dart";
import "../../utils/where_non_null_iterable.dart";
import "../../widgets/search_box_app_bar.dart";
import "../analytics/wiredash/show_feedback_tile.dart";
import "../departments_view/widgets/departments_view_loading.dart";
import "guide_view_controller.dart";
import "repository/guide_repository.dart";
Expand Down Expand Up @@ -47,6 +48,7 @@ class _GuideViewContent extends ConsumerWidget {
children: [
if (!isSomethingSearched) const GuideAboutUsSection(),
for (final item in value.whereNonNull) GuideTile(item),
if (!isSomethingSearched) const ShowFeedbackTile(),
],
),
_ => const Padding(
Expand Down
4 changes: 2 additions & 2 deletions lib/features/parkings_view/api_client/iparking_client.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import "package:dio/dio.dart";
import "package:riverpod_annotation/riverpod_annotation.dart";

import "../../../config/api_base_config.dart";
import "../../../config/env.dart";

part "iparking_client.g.dart";

abstract class ParkingsConfig {
static const parkingsRefreshInterval = Duration(seconds: 30);
static final rootUrl = ApiBaseEnv.iparkingUrl;
static final rootUrl = Env.iparkingUrl;
static const soapEndpoint = "/modules/iparking/scripts/ipk_operations.php";
static String get soapFullUrl => rootUrl + soapEndpoint;

Expand Down
7 changes: 6 additions & 1 deletion lib/l10n/app_pl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,10 @@
"filters" : "Filtry",
"clear" : "Wyczyść",
"filters_didnt_found_anything" : "Nie znaleziono żadnych filtrów",
"street_abbreviation" : "ul."
"street_abbreviation" : "ul.",
"bug_report_title":"Zgłoś błąd lub sugestię",
"bug_report_subtitle":"Kliknij tutaj, aby wysłać zgłoszenie bezpośrednio do twórców aplikacji.",
"new_feature": "Nowa funckcjonalność",
"bug" : "Błąd",
"praise" : "Pochwała"
}
32 changes: 20 additions & 12 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import "package:flutter/material.dart";
import "package:flutter_gen/gen_l10n/app_localizations.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:wiredash/wiredash.dart";

import "config/env.dart";
import "config/ui_config.dart";
import "features/analytics/wiredash/wiredash_theme.dart";
import "features/navigator/app_router.dart";
import "features/splash_screen/splash_screen.dart";
import "features/splash_screen/splash_screen_controller.dart";
Expand All @@ -25,20 +28,25 @@ class MyApp extends ConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
return MaterialApp.router(
title: MyAppConfig.title,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
theme: ThemeData(
extensions: const [AppTheme()],
colorScheme: const ColorScheme.light().copyWith(
surface: ColorsConsts.whiteSoap,
primary: ColorsConsts.orangePomegranade,
secondary: ColorsConsts.blueAzure,
return Wiredash(
projectId: Env.wiredashId,
secret: Env.wiredashSecret,
theme: WiredashTheme.theme,
child: MaterialApp.router(
title: MyAppConfig.title,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
theme: ThemeData(
extensions: const [AppTheme()],
colorScheme: const ColorScheme.light().copyWith(
surface: ColorsConsts.whiteSoap,
primary: ColorsConsts.orangePomegranade,
secondary: ColorsConsts.blueAzure,
),
),
debugShowCheckedModeBanner: false,
routerConfig: ref.watch(appRouterProvider).config(),
),
debugShowCheckedModeBanner: false,
routerConfig: ref.watch(appRouterProvider).config(),
);
}
}
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ dependencies:
url: https://github.com/simon-the-shark/anim_search_bar.git
ref: c56e410
lottie: ^3.1.2
wiredash: ^2.2.1

dev_dependencies:
flutter_test:
Expand Down Expand Up @@ -121,6 +122,7 @@ flutter:
- assets/animations/error.json
- assets/animations/search.json
- assets/animations/offline.json
- assets/animations/bug.json

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
Expand Down

0 comments on commit 8856176

Please sign in to comment.