Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features include displaying names, showcasing a list of members, optimization enhancements, and UI improvements. #227

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
1 change: 0 additions & 1 deletion .fvm/flutter_sdk

This file was deleted.

3 changes: 2 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (localPropertiesFile.exists()) {
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
// throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
Expand All @@ -33,6 +33,7 @@ android {
main.java.srcDirs += 'src/main/kotlin'
}


defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.beacon"
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:label="Beacon"
android:icon="@mipmap/launcher_icon"
android:usesCleartextTraffic="true">
<meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/ANDROID_MAP_API_KEY"/>
<meta-data android:name="com.google.android.geo.API_KEY" android:value="your maps api key"/>
<activity
android:name="io.flutter.embedding.android.FlutterActivity"
android:launchMode="singleTop"
Expand Down
1 change: 1 addition & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:7.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.8'
}
}

Expand Down
43 changes: 27 additions & 16 deletions lib/components/beacon_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,31 @@ import 'package:intl/intl.dart';
class BeaconCustomWidgets {
static final Color textColor = Color(0xFFAFAFAF);

static Widget buildName(Beacon beacon) {
return FutureBuilder(
future: hiveDb!.getCurrentUser(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Text(
'${beacon.title} by ... ',
style: Style.titleTextStyle,
);
} else if (snapshot.hasError || snapshot.data == null) {
return Text(
'${beacon.title} by Anonymous ',
style: Style.titleTextStyle,
);
}
final user = snapshot.data;
return Text(
'${beacon.title} by ${user!.id == beacon.leader!.id ? beacon.leader!.name : beacon.showAdminName == true ? beacon.leader!.name : 'Anonymous'} ',
style: Style.titleTextStyle,
);
},
);
}

static Widget getBeaconCard(BuildContext context, Beacon beacon) {
print(beacon.leader!.name);
bool hasStarted;
bool hasEnded;
bool willStart;
Expand Down Expand Up @@ -78,13 +101,7 @@ class BeaconCustomWidgets {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: 70.w,
child: Text(
'${beacon.title} by ${beacon.leader!.name} ',
style: Style.titleTextStyle,
),
),
Container(width: 70.w, child: buildName(beacon)),
Align(
alignment: Alignment.topRight,
child: BlinkIcon(),
Expand Down Expand Up @@ -134,10 +151,7 @@ class BeaconCustomWidgets {
children: [
Container(
width: 70.w,
child: Text(
'${beacon.title} by ${beacon.leader!.name} ',
style: Style.titleTextStyle,
),
child: buildName(beacon),
),
Align(
alignment: Alignment.topRight,
Expand Down Expand Up @@ -208,10 +222,7 @@ class BeaconCustomWidgets {
children: [
Container(
width: 70.w,
child: Text(
'${beacon.title} by ${beacon.leader!.name} ',
style: Style.titleTextStyle,
),
child: buildName(beacon),
),
SizedBox(height: 4.0),
RichText(
Expand Down
47 changes: 39 additions & 8 deletions lib/components/create_join_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:beacon/utilities/constants.dart';
import 'package:beacon/view_model/group_screen_view_model.dart';
import 'package:duration_picker/duration_picker.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:sizer/sizer.dart';

import '../view_model/home_screen_view_model.dart';
Expand Down Expand Up @@ -154,8 +155,8 @@ class CreateJoinGroupDialog {
}

class CreateJoinBeaconDialog {
static Future createHikeDialog(BuildContext context, GroupViewModel model,
Function reloadList, String? groupID) {
static Future createHikeDialog(
BuildContext context, GroupViewModel model, String? groupID) {
bool isSmallSized = MediaQuery.of(context).size.height < 800;
model.resultingDuration = Duration(minutes: 30);
model.durationController = new TextEditingController();
Expand All @@ -173,7 +174,7 @@ class CreateJoinBeaconDialog {
child: Form(
key: model.formKeyCreate,
child: Container(
height: isSmallSized ? 75.h : 65.h,
height: isSmallSized ? 85.h : 80.h,
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 32, vertical: 16),
Expand Down Expand Up @@ -226,7 +227,7 @@ class CreateJoinBeaconDialog {
data: ThemeData().copyWith(
textTheme: Theme.of(context).textTheme,
colorScheme: ColorScheme.light(
primary: kBlue,
primary: kYellow,
onPrimary: Colors.white,
surface: kBlue,
),
Expand Down Expand Up @@ -397,6 +398,35 @@ class CreateJoinBeaconDialog {
SizedBox(
height: 2.h,
),
Container(
height: isSmallSized ? 14.h : 12.h,
width: 100.w,
child: Padding(
padding: const EdgeInsets.all(4.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Show name',
style: TextStyle(fontSize: 18, color: kYellow),
),
Consumer<GroupViewModel>(
builder: (context, groupviewmodel, child) {
return Switch(
value: groupviewmodel.showName,
onChanged: (value) {
groupviewmodel.toogleShowName(value);
});
},
)
],
),
),
color: kLightBlue,
),
SizedBox(
height: 2.h,
),
Flexible(
flex: 2,
child: HikeButton(
Expand Down Expand Up @@ -426,7 +456,9 @@ class CreateJoinBeaconDialog {
"Enter a valid date and time!!");
return;
}
model.createHikeRoom(groupID, reloadList);
model.createHikeRoom(
groupID,
);
}),
),
],
Expand All @@ -440,8 +472,7 @@ class CreateJoinBeaconDialog {
);
}

static Future joinBeaconDialog(
BuildContext context, GroupViewModel model, Function reloadList) {
static Future joinBeaconDialog(BuildContext context, GroupViewModel model) {
bool isSmallSized = MediaQuery.of(context).size.height < 800;
return showDialog(
context: context,
Expand Down Expand Up @@ -495,7 +526,7 @@ class CreateJoinBeaconDialog {
buttonColor: kYellow,
onTap: () {
// navigationService.pop();
model.joinHikeRoom(reloadList);
model.joinHikeRoom();
},
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/components/hike_screen_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class HikeScreenWidget extends ChangeNotifier {
// All the neccessary info should be here.
//Will be used as subject if shared via email, else isnt used.
// await Share.shareXFiles([XFile(imageFile.path)],
// text: textToShare, subject: subjectToShare);
// text: textToShare, subject: subjectToShare);
//hide after sharing.
await mapController.hideMarkerInfoWindow(MarkerId("1"));
return;
Expand Down
9 changes: 6 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import 'package:beacon/config/environment_config.dart';
import 'package:beacon/locator.dart';
import 'package:beacon/router.dart' as router;
import 'package:beacon/view_model/base_view_model.dart';
import 'package:beacon/view_model/group_screen_view_model.dart';
import 'package:beacon/views/base_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:sizer/sizer.dart';
import 'package:overlay_support/overlay_support.dart';

Expand All @@ -18,8 +20,9 @@ void main() async {
setupLocator();
await localNotif!.initialize();
await hiveDb!.init();
runApp(
OverlaySupport(
runApp(MultiProvider(
providers: [ChangeNotifierProvider(create: (_) => GroupViewModel())],
child: OverlaySupport(
child: Sizer(
builder: (context, orientation, deviceType) => MaterialApp(
debugShowCheckedModeBanner: false,
Expand All @@ -31,7 +34,7 @@ void main() async {
),
),
),
);
));
}

class DemoPageView extends StatelessWidget {
Expand Down
67 changes: 35 additions & 32 deletions lib/models/beacon/beacon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,42 @@ class Beacon extends HiveObject {
this.route,
this.landmarks,
this.location,
this.group});
this.group,
this.showAdminName});

factory Beacon.fromJson(Map<String, dynamic> json) {
return Beacon(
id: json['_id'] as String?,
shortcode: json['shortcode'] as String?,
title: json['title'] != null ? json['title'] as String? : null,
startsAt: json['startsAt'] as int?,
expiresAt: json['expiresAt'] as int?,
leader: json['leader'] != null
? User.fromJson(json['leader'] as Map<String, dynamic>)
: null,
location: json['location'] != null
? Location.fromJson(json['location'] as Map<String, dynamic>)
: null,
followers: json['followers'] != null
? (json['followers'] as List<dynamic>)
.map((e) => User.fromJson(e as Map<String, dynamic>))
.toList()
: [],
route: json['route'] != null
? (json['route'] as List<dynamic>)
.map((e) => Location.fromJson(e as Map<String, dynamic>))
.toList()
: [],
landmarks: json['landmarks'] != null
? (json['landmarks'] as List<dynamic>)
.map((e) => Landmark.fromJson(e as Map<String, dynamic>))
.toList()
: [],
// group: json['group'] != null
// ? Group.fromJson(json['group'] as Map<String, dynamic>)
// : null,
group: json['group'] != null ? json['group']['_id'] : null,
);
id: json['_id'] as String?,
shortcode: json['shortcode'] as String?,
title: json['title'] != null ? json['title'] as String? : null,
startsAt: json['startsAt'] as int?,
expiresAt: json['expiresAt'] as int?,
leader: json['leader'] != null
? User.fromJson(json['leader'] as Map<String, dynamic>)
: null,
location: json['location'] != null
? Location.fromJson(json['location'] as Map<String, dynamic>)
: null,
followers: json['followers'] != null
? (json['followers'] as List<dynamic>)
.map((e) => User.fromJson(e as Map<String, dynamic>))
.toList()
: [],
route: json['route'] != null
? (json['route'] as List<dynamic>)
.map((e) => Location.fromJson(e as Map<String, dynamic>))
.toList()
: [],
landmarks: json['landmarks'] != null
? (json['landmarks'] as List<dynamic>)
.map((e) => Landmark.fromJson(e as Map<String, dynamic>))
.toList()
: [],
// group: json['group'] != null
// ? Group.fromJson(json['group'] as Map<String, dynamic>)
// : null,
group: json['group'] != null ? json['group']['_id'] : null,
showAdminName: json['showAdminName'] ?? false);
}

@HiveField(0)
Expand All @@ -78,6 +79,8 @@ class Beacon extends HiveObject {
Location? location;
@HiveField(10)
String? group;
@HiveField(11)
bool? showAdminName;

print() {
debugPrint('shortCode: ${this.shortcode}');
Expand Down
11 changes: 7 additions & 4 deletions lib/models/beacon/beacon.g.dart

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

3 changes: 0 additions & 3 deletions lib/queries/auth.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:developer';

class AuthQueries {
String registerUser(String? name, String email, String? password) {
return '''
Expand Down Expand Up @@ -43,7 +41,6 @@ class AuthQueries {
}

String fetchUserInfo() {
log('fetching user info');
return '''
query{
me{
Expand Down
Loading
Loading