Skip to content
Merged

Dev #13

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
69 changes: 36 additions & 33 deletions lib/features/overview/widgets/stat_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,44 +28,47 @@ class StatCard extends StatelessWidget {
Text(NumberFormat.compact().format((stat.value as Map)['value']),
style: kTitleTextStyle.copyWith(
fontSize: kTitleTextStyle.fontSize! + 8)),
Container(
padding: EdgeInsets.symmetric(horizontal: 14.0, vertical: 4),
decoration: BoxDecoration(
color: percentage.isNegative
? kErrorColor.withOpacity(.2)
: kSuccessColor.withOpacity(.2),
borderRadius: BorderRadius.circular(20.0),
border: Border.all(
if (stat.value['prev'] != -1)
Container(
padding: EdgeInsets.symmetric(horizontal: 14.0, vertical: 4),
decoration: BoxDecoration(
color: percentage.isNegative
? kErrorColor.withOpacity(.5)
: kSuccessColor.withOpacity(.5),
width: 2.0,
? kErrorColor.withOpacity(.2)
: kSuccessColor.withOpacity(.2),
borderRadius: BorderRadius.circular(20.0),
border: Border.all(
color: percentage.isNegative
? kErrorColor.withOpacity(.5)
: kSuccessColor.withOpacity(.5),
width: 2.0,
),
),
),
child: Row(
mainAxisSize: MainAxisSize.min,
spacing: 10,
children: [
Visibility(
visible: percentage != 0,
child: Icon(
percentage.isNegative
? Bootstrap.arrow_down_left_circle_fill
: Bootstrap.arrow_up_right_circle_fill,
color: percentage.isNegative ? kErrorColor : kSuccessColor,
size: 18,
child: Row(
mainAxisSize: MainAxisSize.min,
spacing: 10,
children: [
Visibility(
visible: percentage != 0,
child: Icon(
percentage.isNegative
? Bootstrap.arrow_down_left_circle_fill
: Bootstrap.arrow_up_right_circle_fill,
color:
percentage.isNegative ? kErrorColor : kSuccessColor,
size: 18,
),
),
),
Text(
'${percentage.toStringAsFixed(1).replaceAll('-', '')} %',
style: kBodyTextStyle.copyWith(
color: percentage.isNegative ? kErrorColor : kSuccessColor,
fontWeight: FontWeight.w600,
Text(
'${percentage.toStringAsFixed(1).replaceAll('-', '')} %',
style: kBodyTextStyle.copyWith(
color:
percentage.isNegative ? kErrorColor : kSuccessColor,
fontWeight: FontWeight.w600,
),
),
),
],
],
),
),
),
],
),
);
Expand Down
16 changes: 14 additions & 2 deletions lib/features/sessions/model/session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,26 @@ part 'session.g.dart';
class Session {
String id;
String browser;
String websiteId;
String os;
String device;
String screen;
String country;
String language;
String region;
String city;
int visits;
int views;
DateTime createdAt;
int? totaltime;
int? events;
DateTime? createdAt;
DateTime firstAt;
DateTime lastAt;

Session({
required this.browser,
required this.createdAt,
required this.websiteId,
this.createdAt,
required this.city,
required this.country,
required this.device,
Expand All @@ -27,6 +34,11 @@ class Session {
required this.screen,
required this.visits,
required this.views,
required this.firstAt,
required this.lastAt,
required this.language,
this.events,
this.totaltime,
});

factory Session.fromJson(Map<String, dynamic> json) =>
Expand Down
18 changes: 16 additions & 2 deletions lib/features/sessions/model/session.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions lib/features/sessions/repo/sessions_repo.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:pulse/features/sessions/model/session.dart';
import 'package:pulse/utils/endpoints.dart';
import 'package:pulse/utils/requests.dart';
import 'package:pulse/utils/utils.dart';

class SessionsRepo {
Future<List<Session>> getSessions({
Expand All @@ -20,4 +21,13 @@ class SessionsRepo {
'${Endpoints.websites.replaceAll(Endpoints.baseUrl, 'https://api.umami.is/v1')}/$id/sessions?startAt=$startAt&endAt=$endAt&pageSize=20&page=${pageNumber ?? 1}');
return Session.toList(res['data']);
}

Future<Session?> getSession(String websiteId, String id) async {
var res = await Requests.get(
useKey: true,
endpoint:
'${Endpoints.websites.replaceAll(Endpoints.baseUrl, 'https://api.umami.is/v1')}/$websiteId/sessions/$id');

return Session.fromJson(res);
}
}
Loading
Loading