Skip to content

Commit

Permalink
Adding basic plausible usage tracking (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
clone1018 authored Mar 11, 2022
1 parent 6eefb26 commit 532ec30
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 64 deletions.
6 changes: 3 additions & 3 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 26;
CURRENT_PROJECT_VERSION = 27;
DEVELOPMENT_TEAM = 3TCN256Z4Z;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
Expand Down Expand Up @@ -488,7 +488,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 26;
CURRENT_PROJECT_VERSION = 27;
DEVELOPMENT_TEAM = 3TCN256Z4Z;
ENABLE_BITCODE = NO;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "i386 arm64";
Expand All @@ -514,7 +514,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 26;
CURRENT_PROJECT_VERSION = 27;
DEVELOPMENT_TEAM = 3TCN256Z4Z;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
Expand Down
2 changes: 1 addition & 1 deletion ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>26</string>
<string>27</string>
<key>CFBundleLocalizations</key>
<array>
<string>cs</string>
Expand Down
33 changes: 20 additions & 13 deletions lib/blocs/repos/channel_list_bloc.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:math';

import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Expand All @@ -9,33 +11,29 @@ import 'package:glimesh_app/i18n.dart';
@immutable
abstract class ChannelListEvent extends Equatable {}

class LoadChannels extends ChannelListEvent {
abstract class AlwaysRefreshingChannelListEvent extends ChannelListEvent {
@override
List<Object> get props => [Random().nextInt(1000)];
}

class LoadChannels extends AlwaysRefreshingChannelListEvent {
final String categorySlug;
final int channelLimit;

LoadChannels({required this.categorySlug, this.channelLimit: 15});

@override
String toString() => 'LoadChannels';

@override
List<Object> get props => [this.categorySlug, this.channelLimit];
}

class LoadMyLiveFollowedChannels extends ChannelListEvent {
class LoadMyLiveFollowedChannels extends AlwaysRefreshingChannelListEvent {
@override
String toString() => 'LoadMyLiveFollowedChannels';

@override
List<Object> get props => [];
}

class LoadHomepageChannels extends ChannelListEvent {
class LoadHomepageChannels extends AlwaysRefreshingChannelListEvent {
@override
String toString() => 'LoadHomepageChannels';

@override
List<Object> get props => [];
}

@immutable
Expand All @@ -55,7 +53,7 @@ class ChannelListLoaded extends ChannelListState {
ChannelListLoaded({required this.results});

@override
List<Object> get props => [results];
List<Object> get props => results.map((e) => e.id).toList();
}

class ChannelListNotLoaded extends ChannelListState {
Expand Down Expand Up @@ -85,10 +83,13 @@ class ChannelListBloc extends Bloc<ChannelListEvent, ChannelListState> {
_loadChannels(LoadChannels event, Emitter emit) async {
emit(ChannelListLoading());

print("inside");

final queryResults =
await this.glimeshRepository.getLiveChannels(event.categorySlug);

if (queryResults.hasException) {
print(queryResults.hasException);
emit(ChannelListNotLoaded(queryResults.exception!.graphqlErrors));
return;
}
Expand All @@ -101,6 +102,12 @@ class ChannelListBloc extends Bloc<ChannelListEvent, ChannelListState> {

listOfChannels.shuffle();

print('map');
listOfChannels.forEach((e) {
print(e.id);
print(e.title);
});

emit(ChannelListLoaded(results: listOfChannels));
}

Expand Down
1 change: 1 addition & 0 deletions lib/components/FTLPlayer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class _FTLPlayerState extends State<FTLPlayer> {
Image.network(widget.channel.thumbnail),
Container(
decoration: BoxDecoration(color: Colors.black45),
child: Loading("Loading Video"),
),
_errored
? Center(
Expand Down
8 changes: 8 additions & 0 deletions lib/components/StreamTitle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class _StreamTitleState extends State<StreamTitle> {
padding: EdgeInsets.all(20),
child: ListView(
children: [
_buildTitleTag(),
_buildSubcategoryTag(),
_buildTags(context),
_buildLanguageTag(context),
Expand All @@ -85,6 +86,13 @@ class _StreamTitleState extends State<StreamTitle> {
);
}

Widget _buildTitleTag() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [Text("Title"), Chip(label: Text(widget.channel.title))],
);
}

Widget _buildSubcategoryTag() {
if (widget.channel.subcategory == null) {
return Padding(padding: EdgeInsets.zero);
Expand Down
5 changes: 5 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:glimesh_app/blocs/repos/chat_messages_bloc.dart';
import 'package:glimesh_app/blocs/repos/follow_bloc.dart';
import 'package:glimesh_app/blocs/repos/settings_bloc.dart';
import 'package:glimesh_app/screens/AppScreen.dart';
import 'package:glimesh_app/track.dart';
import 'package:gql_phoenix_link/gql_phoenix_link.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
Expand Down Expand Up @@ -252,6 +253,8 @@ class GlimeshApp extends StatelessWidget {
final ChannelBloc bloc = ChannelBloc(
glimeshRepository: repo,
);

track.event(page: "${channel.username}");

return MaterialPageRoute(
builder: (context) {
Expand Down Expand Up @@ -291,6 +294,8 @@ class GlimeshApp extends StatelessWidget {

if (settings.name == '/profile') {
final String username = settings.arguments as String;

track.event(page: "${username}/profile");

return MaterialPageRoute(
builder: (context) {
Expand Down
10 changes: 8 additions & 2 deletions lib/screens/AppScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import 'package:glimesh_app/screens/CategoryListScreen.dart';
import 'package:glimesh_app/screens/FollowingScreen.dart';
import 'package:glimesh_app/auth.dart';

import 'package:glimesh_app/track.dart';

class AppScreen extends StatefulWidget {
AppScreen({Key? key, required this.title}) : super(key: key);

Expand Down Expand Up @@ -34,6 +36,8 @@ class _AppScreenState extends State<AppScreen> {
void initState() {
super.initState();

track.event();

setState(() {
pages = [
MyProfileScreen(),
Expand Down Expand Up @@ -106,7 +110,8 @@ class _AppScreenState extends State<AppScreen> {
],
),
),
body: pages.isEmpty ? Loading(context.t("Loading")) : pages[_selectedIndex],
body:
pages.isEmpty ? Loading(context.t("Loading")) : pages[_selectedIndex],
bottomNavigationBar:
_bottomNavigationBar(context, authState.authenticated),
);
Expand All @@ -115,7 +120,8 @@ class _AppScreenState extends State<AppScreen> {
Widget _anonymousUserInfo(BuildContext context, bool shown) {
if (shown) {
return ListTile(
title: Text(context.t("Login to experience the very best Glimesh has to offer!")),
title: Text(context
.t("Login to experience the very best Glimesh has to offer!")),
);
} else {
return SizedBox();
Expand Down
1 change: 1 addition & 0 deletions lib/screens/CategoryListScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:glimesh_app/blocs/repos/channel_list_bloc.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:glimesh_app/repository.dart';
import 'package:gettext_i18n/gettext_i18n.dart';
import 'package:glimesh_app/track.dart';

class CategoryListScreen extends StatelessWidget {
@override
Expand Down
3 changes: 3 additions & 0 deletions lib/screens/ChannelListScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import 'package:glimesh_app/repository.dart';
import 'package:glimesh_app/models.dart';
import 'package:glimesh_app/auth.dart';
import 'package:gettext_i18n/gettext_i18n.dart';
import 'package:glimesh_app/track.dart';

class ChannelListScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
Category category = ModalRoute.of(context)!.settings.arguments as Category;
final authState = AuthState.of(context);

track.event(page: "streams/${category.slug}");

return Scaffold(
appBar: AppBar(
title: Text(context
Expand Down
4 changes: 4 additions & 0 deletions lib/screens/FollowingScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ import 'package:glimesh_app/components/Loading.dart';
import 'package:glimesh_app/repository.dart';
import 'package:glimesh_app/models.dart';
import 'package:gettext_i18n/gettext_i18n.dart';
import 'package:glimesh_app/track.dart';

class FollowingScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final authState = AuthState.of(context);

track.event(page: "streams/following");

return Scaffold(
body: BlocProvider(
create: (context) => ChannelListBloc(
Expand Down
91 changes: 47 additions & 44 deletions lib/screens/LoginScreen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:glimesh_app/glimesh.dart';
import 'package:glimesh_app/auth.dart';
import 'package:glimesh_app/track.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:package_info_plus/package_info_plus.dart';
Expand All @@ -14,11 +15,27 @@ class LoginScreen extends StatelessWidget {
authState = AuthState.of(context);
bool horizontalTablet = MediaQuery.of(context).size.width > 992;

track.event(page: "users/log_in");

return Scaffold(
body: SafeArea(
child: horizontalTablet
? _buildHorizontal(context)
: _buildVertical(context),
child: Stack(
children: [
horizontalTablet
? _buildHorizontal(context)
: _buildVertical(context),
InkWell(
child: Padding(
padding: EdgeInsets.all(5),
child: Icon(
Icons.chevron_left,
color: Colors.white70,
),
),
onTap: () => Navigator.pop(context),
)
],
),
),
);
}
Expand All @@ -37,22 +54,7 @@ class LoginScreen extends StatelessWidget {
child: _loginButton(context, true),
),
),
FutureBuilder<PackageInfo>(
future: PackageInfo.fromPlatform(),
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.done:
return Align(
alignment: Alignment.bottomCenter,
child: Text(
'Version: ${snapshot.data!.version}+${snapshot.data!.buildNumber}',
),
);
default:
return const SizedBox();
}
},
),
_versionWidget(),
],
));
}
Expand All @@ -68,28 +70,36 @@ class LoginScreen extends StatelessWidget {
Expanded(
child: _loginButton(context, false),
),
FutureBuilder<PackageInfo>(
future: PackageInfo.fromPlatform(),
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.done:
return Align(
alignment: Alignment.bottomCenter,
child: Text(
'Version: ${snapshot.data!.version}+${snapshot.data!.buildNumber}',
),
);
default:
return const SizedBox();
}
},
),
_versionWidget()
],
);
}

Widget _versionWidget() {
return FutureBuilder<PackageInfo>(
future: PackageInfo.fromPlatform(),
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.done:
return Align(
alignment: Alignment.bottomCenter,
child: Text(
'Version: ${snapshot.data!.version}+${snapshot.data!.buildNumber}',
style: Theme.of(context).textTheme.caption,
),
);
default:
return const SizedBox();
}
},
);
}

Widget _logo() {
return Image.asset('assets/images/logo-with-text.png');
return Padding(
padding: EdgeInsets.only(left: 20, right: 20),
child: Image.asset('assets/images/logo-with-text.png'),
);
}

Widget _loginButton(BuildContext context, bool center) {
Expand Down Expand Up @@ -125,17 +135,10 @@ class LoginScreen extends StatelessWidget {
// Later once "state" is figured out, this can be just .pop to go back to the last page
Navigator.popUntil(context, ModalRoute.withName('/'));
},
child: Text(context.t("Login")),
child: Text(context.t("Login or Register")),
),
),
Padding(padding: EdgeInsets.only(top: 20)),
Center(
child: Text(
context.t(
"If you need to register, please visit Glimesh.tv on your phone or computer."),
textAlign: center ? TextAlign.center : TextAlign.left,
),
)
],
),
);
Expand Down
Loading

0 comments on commit 532ec30

Please sign in to comment.