Skip to content
Merged

Dev #17

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/google_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ jobs:
flutter-version: '3.27.2' # Specify your Flutter version
channel: 'stable'

- name: Create .env file
run: |
echo "${{ secrets.ENV_FILE }}" > .env

- name: Install dependencies
run: flutter pub get

Expand Down
16 changes: 16 additions & 0 deletions lib/features/auth/screens/splash_screen.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:in_app_update/in_app_update.dart';
import 'package:pulse/features/websites/screens/websites_screen.dart';
import 'package:pulse/utils/local_storage.dart';
import 'package:pulse/utils/navigation.dart';
Expand All @@ -18,7 +19,10 @@ class _SplashScreenState extends State<SplashScreen> {
@override
void initState() {
Future.delayed(Duration(seconds: 2)).then((_) async {
checkForUpdate();

String? token = prefs.getString(LocalStorage.jwt);

Navigation.go(
screen: token != null ? WebsitesScreen() : SignInScreen(),
context: context,
Expand All @@ -28,6 +32,18 @@ class _SplashScreenState extends State<SplashScreen> {
super.initState();
}

Future<void> checkForUpdate() async {
InAppUpdate.checkForUpdate().then((info) {
if (info.updateAvailability == UpdateAvailability.updateAvailable) {
Toast.showToast(
message: 'New App Update Available! 🎉', context: context);
}
}).catchError((e) {
logger.e(e);
Toast.showToast(message: e.toString(), context: context);
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down
4 changes: 2 additions & 2 deletions lib/features/sessions/cubit/sessions_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class SessionsCubit extends Cubit<SessionsState> {
Future<void> getSessionEvents({
required String websiteId,
required String id,
DateTime? start,
DateTime? end,
required DateTime start,
required DateTime end,
}) async {
emit(state.copyWith(appState: AppState.loading, events: []));
try {
Expand Down
11 changes: 4 additions & 7 deletions lib/features/sessions/repo/sessions_repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,15 @@ class SessionsRepo {
Future<List<Event>> getSessionEvents({
required String websiteId,
required String id,
DateTime? start,
DateTime? end,
required DateTime start,
required DateTime end,
}) async {
var now = DateTime.now();
int startAt = (start ?? now.subtract(const Duration(hours: 24)))
.millisecondsSinceEpoch;
int endAt = (end ?? now).millisecondsSinceEpoch;
int startAt = (start).millisecondsSinceEpoch;
int endAt = (end).millisecondsSinceEpoch;
var res = await Requests.get(
useKey: true,
endpoint:
'${Endpoints.websites.replaceAll(Endpoints.baseUrl, 'https://api.umami.is/v1')}/$websiteId/sessions/$id/activity?startAt=$startAt&endAt=$endAt');
logger.i(res);
return Event.toList(res);
}
}
33 changes: 19 additions & 14 deletions lib/features/sessions/screens/session_details_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,20 @@ class SessionDetailsScreen extends StatefulWidget {

class _SessionDetailsScreenState extends State<SessionDetailsScreen> {
Session? _session;
DateTimeRange? range;

late DateTimeRange range;

@override
void initState() {
range = DateTimeRange(
start: widget.session.lastAt.subtract(const Duration(days: 5)),
end: widget.session.lastAt,
);
context.read<SessionsCubit>().getSessionEvents(
websiteId: widget.session.websiteId,
id: widget.session.id,
end: range.end,
start: range.start,
);
Future.delayed(Duration.zero).then((_) async {
try {
Expand Down Expand Up @@ -196,10 +203,7 @@ class _SessionDetailsScreenState extends State<SessionDetailsScreen> {
DropDownBtn(
click: () async {
DateTimeRange? picked = await showDateRangePicker(
initialDateRange: range ??
DateTimeRange(
start: DateTime.now().subtract(Duration(days: 3)),
end: DateTime.now()),
initialDateRange: range,
context: context,
firstDate: DateTime(2000),
lastDate: DateTime.now(),
Expand All @@ -210,14 +214,13 @@ class _SessionDetailsScreenState extends State<SessionDetailsScreen> {
context.read<SessionsCubit>().getSessionEvents(
websiteId: widget.session.websiteId,
id: widget.session.id,
end: range?.end,
start: range?.start,
end: range.end,
start: range.start,
);
},
icon: Iconsax.timer_1_bold,
title: range == null
? 'Last 24 hours'
: 'From ${DateFormat('EEE, MMM dd, yyyy').format(range!.start)} - ${DateFormat('EEE, MMM dd, yyyy').format(range!.end)}',
title:
'From ${DateFormat('EEE, MMM dd, yyyy').format(range.start)} - ${DateFormat('EEE, MMM dd, yyyy').format(range.end)}',
),
BlocConsumer<SessionsCubit, SessionsState>(
listener: (context, state) {
Expand Down Expand Up @@ -271,12 +274,14 @@ class _SessionDetailsScreenState extends State<SessionDetailsScreen> {
style: kBodyTitleTextStyle.copyWith(fontWeight: FontWeight.bold)),
Row(
spacing: 5,
crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if (icon != null) icon,
Text(
des,
style: kBodyTextStyle,
Expanded(
child: Text(
des,
style: kBodyTextStyle,
),
),
],
),
Expand Down
15 changes: 13 additions & 2 deletions lib/features/settings/screens/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,21 @@ class _SettingsScreenState extends State<SettingsScreen> {
//setting
Btn(
title: 'App version',
des: '${packageInfo?.version} (#${packageInfo?.buildNumber})',
des: _updateInfo?.updateAvailability ==
UpdateAvailability.updateAvailable
? 'Click to update the app 🚀'
: '${packageInfo?.version} (#${packageInfo?.buildNumber})',
type: 'setting',
icon: Icons.info_rounded,
click: () {},
click: () async {
if (_updateInfo?.updateAvailability ==
UpdateAvailability.updateAvailable) {
await InAppUpdate.performImmediateUpdate();
} else {
Toast.showToast(
message: 'You are using the latest version!', context: context);
}
},
),

Btn(
Expand Down
8 changes: 8 additions & 0 deletions lib/utils/utils.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:in_app_update/in_app_update.dart';
import 'package:logger/logger.dart';
import 'package:pulse/utils/text.dart';
import 'package:shared_preferences/shared_preferences.dart';
Expand Down Expand Up @@ -34,6 +35,13 @@ class Toast {
}
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
action: message.contains('App Update')
? SnackBarAction(
label: 'Update!',
onPressed: () async {
await InAppUpdate.performImmediateUpdate();
})
: null,
behavior: SnackBarBehavior.floating,
content: Text(
errMessage.trim(),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: "A new Flutter project."
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: "none" # Remove this line if you wish to publish to pub.dev

version: 1.0.3+4
version: 1.0.4+5

environment:
sdk: ^3.6.1
Expand Down
Loading