Skip to content

Commit

Permalink
Merge pull request #170 from takenet/feature/release-0-0-64
Browse files Browse the repository at this point in the history
Feature/release 0 0 64
  • Loading branch information
mpamaro authored Jul 17, 2023
2 parents 568e200 + eecbca3 commit 01b6cd6
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 25 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.64

- [DSLocationMessageBubble] New widget to show the content of location card

## 0.0.63

- [DSAuthService] New service that handles HTTP Requests authentication.
Expand Down
2 changes: 2 additions & 0 deletions lib/blip_ds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export 'src/widgets/chat/ds_file_message_bubble.widget.dart'
show DSFileMessageBubble;
export 'src/widgets/chat/ds_image_message_bubble.widget.dart'
show DSImageMessageBubble;
export 'src/widgets/chat/ds_location_message_bubble.widget.dart'
show DSLocationMessageBubble;
export 'src/widgets/chat/ds_message_bubble.widget.dart' show DSMessageBubble;
export 'src/widgets/chat/ds_message_bubble_detail.widget.dart'
show DSMessageBubbleDetail;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/controllers/ds_video_player.controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class DSVideoPlayerController extends GetxController {

Future<void> _initializePlayer() async {
try {
_videoPlayerController = VideoPlayerController.network(
url,
_videoPlayerController = VideoPlayerController.networkUrl(
Uri.parse(url),
httpHeaders: shouldAuthenticate
? DSAuthService.httpHeaders
: const <String, String>{},
Expand Down
26 changes: 9 additions & 17 deletions lib/src/services/ds_auth.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,19 @@ abstract class DSAuthService {
static String? _token;
static String? get token => _token;

static void init({
required final String userAccessToken,
static void setUser({
required final String accessToken,
}) {
assert(userAccessToken.isNotEmpty, 'The token must not be empty.');
assert(_token == null, 'The DSAuthService was already initialized.');

_token = userAccessToken;
_token = accessToken;
}

static void dispose() {
static void clearUser() {
_token = null;
}

static Map<String, String> get httpHeaders {
assert(
token?.isNotEmpty ?? false,
'The DSAuthService must be initialized.',
);

return {
'Authorization': 'Key $token',
};
}
static Map<String, String> get httpHeaders => token?.isNotEmpty ?? false
? {
'Authorization': 'Key $token',
}
: const {};
}
1 change: 1 addition & 0 deletions lib/src/utils/ds_message_content_type.util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ abstract class DSMessageContentType {
static const String collection = 'application/vnd.lime.collection+json';
static const String ticket = 'application/vnd.iris.ticket+json';
static const String contact = 'application/vnd.lime.contact+json';
static const String location = 'application/vnd.lime.location+json';
}
104 changes: 104 additions & 0 deletions lib/src/widgets/chat/ds_location_message_bubble.widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import 'package:flutter/material.dart';
import 'package:map_launcher/map_launcher.dart';

import '../../enums/ds_align.enum.dart';
import '../../models/ds_message_bubble_style.model.dart';
import '../../themes/colors/ds_colors.theme.dart';
import '../animations/ds_spinner_loading.widget.dart';
import '../texts/ds_body_text.widget.dart';
import '../utils/ds_cached_network_image_view.widget.dart';
import 'ds_message_bubble.widget.dart';

class DSLocationMessageBubble extends StatelessWidget {
final DSAlign align;
final DSMessageBubbleStyle style;
final String? title;
final double latitude;
final double longitude;

DSLocationMessageBubble({
super.key,
required this.align,
required this.latitude,
required this.longitude,
DSMessageBubbleStyle? style,
this.title,
}) : style = style ?? DSMessageBubbleStyle();

final appKey = 'AIzaSyAlC3a3DZZBscR0QIbQpee13Op9Y05m_wc';

@override
Widget build(BuildContext context) {
final foregroundColor = style.isLightBubbleBackground(align)
? DSColors.neutralDarkCity
: DSColors.neutralLightSnow;

return GestureDetector(
onTap: () async {
final availableMaps = await MapLauncher.installedMaps;

await availableMaps.first.showMarker(
coords: Coords(latitude, longitude),
title: "Ocean Beach",
);
},
child: DSMessageBubble(
shouldUseDefaultSize: true,
defaultMaxSize: 240.0,
defaultMinSize: 240.0,
padding: EdgeInsets.zero,
align: align,
style: style,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
DSCachedNetworkImageView(
url:
'https://maps.googleapis.com/maps/api/staticmap?&size=360x360&markers=$latitude,$longitude&key=$appKey',
placeholder: (_, __) => _buildLoading(),
align: align,
style: style,
),
if (title?.isNotEmpty ?? false)
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16.0,
vertical: 8.0,
),
child: Align(
alignment: Alignment.topLeft,
child: DSBodyText(
title!,
color: foregroundColor,
isSelectable: true,
overflow: TextOverflow.visible,
),
),
),
],
),
),
);
}

Widget _buildLoading() => Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.symmetric(
vertical: 8.0,
),
child: Center(
child: DSSpinnerLoading(
color: style.isLightBubbleBackground(align)
? DSColors.primaryNight
: DSColors.neutralLightSnow,
size: 32.0,
lineWidth: 4.0,
),
),
),
],
);
}
9 changes: 9 additions & 0 deletions lib/src/widgets/utils/ds_card.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import '../chat/ds_carrousel.widget.dart';
import '../chat/ds_contact_message_bubble.widget.dart';
import '../chat/ds_file_message_bubble.widget.dart';
import '../chat/ds_image_message_bubble.widget.dart';
import '../chat/ds_location_message_bubble.widget.dart';
import '../chat/ds_quick_reply.widget.dart';
import '../chat/ds_text_message_bubble.widget.dart';
import '../chat/ds_unsupported_content_message_bubble.widget.dart';
Expand Down Expand Up @@ -97,6 +98,14 @@ class DSCard extends StatelessWidget {
style: style,
);

case DSMessageContentType.location:
return DSLocationMessageBubble(
title: content['text'],
latitude: content['latitude'],
longitude: content['longitude'],
align: align,
style: style,
);
case DSMessageContentType.ticket:
return DSTicketMessage(
messageType: DSTicketMessageType.forwardedTicket,
Expand Down
5 changes: 3 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: blip_ds
description: Blip Design System for Flutter.
version: 0.0.63
version: 0.0.64
homepage: https://github.com/takenet/blip-ds-flutter#readme
repository: https://github.com/takenet/blip-ds-flutter

Expand Down Expand Up @@ -29,14 +29,15 @@ dependencies:
simple_link_preview: ^1.0.2
simple_animations: ^5.0.0
chewie: ^1.3.4
video_player: ^2.5.1
video_player: ^2.7.0
sticky_headers: ^0.3.0
pointer_interceptor: ^0.9.1
debounce_throttle: ^2.0.0
file_sizes: ^1.0.6
intl_phone_number_input: ^0.7.3+1
mask_text_input_formatter: ^2.4.0
dotted_border: ^2.0.0+3
map_launcher: ^2.5.0+1

dev_dependencies:
flutter_test:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ class SampleMessageBubbleShowcase extends StatelessWidget {
DSSurveyMessageBubble(
align: DSAlign.center,
),
DSLocationMessageBubble(
align: DSAlign.left,
latitude: 47.5951518,
longitude: 122.3316393,
),
],
),
);
Expand Down
8 changes: 4 additions & 4 deletions sample/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -848,10 +848,10 @@ packages:
dependency: transitive
description:
name: video_player
sha256: "59f7f31c919c59cbedd37c617317045f5f650dc0eeb568b0b0de9a36472bdb28"
sha256: "3fd106c74da32f336dc7feb65021da9b0207cb3124392935f1552834f7cce822"
url: "https://pub.dev"
source: hosted
version: "2.5.1"
version: "2.7.0"
video_player_android:
dependency: transitive
description:
Expand All @@ -872,10 +872,10 @@ packages:
dependency: transitive
description:
name: video_player_platform_interface
sha256: "42bb75de5e9b79e1f20f1d95f688fac0f95beac4d89c6eb2cd421724d4432dae"
sha256: a8c4dcae2a7a6e7cc1d7f9808294d968eca1993af34a98e95b9bdfa959bec684
url: "https://pub.dev"
source: hosted
version: "6.0.1"
version: "6.1.0"
video_player_web:
dependency: transitive
description:
Expand Down

0 comments on commit 01b6cd6

Please sign in to comment.