Compare commits
2 Commits
33bd2b97a1
...
minimal
| Author | SHA1 | Date | |
|---|---|---|---|
| 2cd685b65e | |||
| a358f65853 |
12
lib/common/state/game/game_binding.dart
Normal file
12
lib/common/state/game/game_binding.dart
Normal file
@ -0,0 +1,12 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/common/state/game/game_controller.dart';
|
||||
import 'package:rogapp/screens/auth/controller/auth_controller.dart';
|
||||
|
||||
class GameBinding extends Bindings{
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut<AuthController>(() => AuthController());
|
||||
Get.put<GameController>(GameController());
|
||||
}
|
||||
|
||||
}
|
||||
25
lib/common/state/game/game_controller.dart
Normal file
25
lib/common/state/game/game_controller.dart
Normal file
@ -0,0 +1,25 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/model/user.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/screens/auth/controller/auth_controller.dart';
|
||||
|
||||
class GameController extends GetxController{
|
||||
|
||||
AuthController authController = Get.find<AuthController>();
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
ever(authController.authList, changeInAuth);
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
void changeInAuth(List<AuthResponse> change){
|
||||
if(change.isNotEmpty){
|
||||
Get.toNamed(AppPages.S_HOME);
|
||||
}
|
||||
else{
|
||||
Get.toNamed(AppPages.S_LOGIN);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
16
lib/common/ui/widgets/uis.dart
Normal file
16
lib/common/ui/widgets/uis.dart
Normal file
@ -0,0 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rogapp/theme/theme.dart';
|
||||
|
||||
class UIs{
|
||||
static AppBar appBar(){
|
||||
return AppBar(
|
||||
title: const Icon(
|
||||
Icons.access_alarm,
|
||||
size:30,
|
||||
color: Pallete.WHITE_COLOR,
|
||||
),
|
||||
automaticallyImplyLeading:false,
|
||||
centerTitle: true,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -6,8 +6,10 @@ import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:rogapp/common/state/game/game_binding.dart';
|
||||
import 'package:rogapp/pages/index/index_binding.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/theme/theme.dart';
|
||||
import 'package:rogapp/utils/string_values.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
@ -46,18 +48,14 @@ class MyApp extends StatelessWidget {
|
||||
//locale: const Locale('en', 'US'),
|
||||
fallbackLocale: const Locale('en', 'US'),
|
||||
title: 'ROGAINING',
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.blue,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
textTheme: GoogleFonts.muliTextTheme(),
|
||||
),
|
||||
theme: AppTheme.theme,
|
||||
debugShowCheckedModeBanner: false,
|
||||
defaultTransition: Transition.cupertino,
|
||||
opaqueRoute: Get.isOpaqueRouteDefault,
|
||||
popGesture: Get.isPopGestureEnable,
|
||||
transitionDuration: const Duration(milliseconds: 230),
|
||||
initialBinding: IndexBinding(), //HomeBinding(),
|
||||
initialRoute: AppPages.PERMISSION,
|
||||
initialBinding: GameBinding(),
|
||||
initialRoute: AppPages.S_LOGIN,
|
||||
getPages: AppPages.routes,
|
||||
enableLog: true,
|
||||
);
|
||||
|
||||
591
lib/model/location_response.dart
Normal file
591
lib/model/location_response.dart
Normal file
@ -0,0 +1,591 @@
|
||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:unicode/unicode.dart';
|
||||
|
||||
class LocationResponse {
|
||||
List<Feature>? features;
|
||||
String? type;
|
||||
|
||||
LocationResponse({
|
||||
this.features,
|
||||
this.type,
|
||||
});
|
||||
|
||||
LocationResponse copyWith({
|
||||
List<Feature>? features,
|
||||
String? type,
|
||||
}) {
|
||||
return LocationResponse(
|
||||
features: features ?? this.features,
|
||||
type: type ?? this.type,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'features': features?.map((x) => x.toMap()).toList(),
|
||||
'type': type,
|
||||
};
|
||||
}
|
||||
|
||||
factory LocationResponse.fromMap(Map<String, dynamic> map) {
|
||||
return LocationResponse(
|
||||
features: List<Feature>.from(map['features']?.map((x) => Feature.fromMap(x)) ?? const []),
|
||||
type: map['type'],
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory LocationResponse.fromJson(String source) =>
|
||||
LocationResponse.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() => 'LocationResponse(features: $features, type: $type)';
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is LocationResponse &&
|
||||
listEquals(other.features, features) &&
|
||||
other.type == type;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => features.hashCode ^ type.hashCode;
|
||||
}
|
||||
|
||||
class Feature {
|
||||
Geometry? geometry;
|
||||
int? id;
|
||||
Properties? properties;
|
||||
String? type;
|
||||
int? location_id;
|
||||
double? latitude;
|
||||
double? longitude;
|
||||
|
||||
Feature({
|
||||
this.geometry,
|
||||
this.id,
|
||||
this.properties,
|
||||
this.type,
|
||||
this.location_id,
|
||||
this.latitude,
|
||||
this.longitude
|
||||
});
|
||||
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return <String, dynamic>{
|
||||
'id': id,
|
||||
'geometry': geometry?.toJson(),
|
||||
'properties': properties?.toJson(),
|
||||
'type': type,
|
||||
// Use the first coordinate as latitude and longitude.
|
||||
// You may need to adjust this based on your actual data structure.
|
||||
'location_id': properties?.location_id,
|
||||
'latitude': geometry?.coordinates?.first?.last,
|
||||
'longitude': geometry?.coordinates?.first?.first,
|
||||
};
|
||||
}
|
||||
|
||||
// factory Feature.fromMap(Map<String, dynamic> map) {
|
||||
// return Feature(
|
||||
// geometry: Geometry.fromMap(map['geometry']),
|
||||
// id: map['id'],
|
||||
// properties: Properties.fromMap(map['properties']),
|
||||
// type: map['type'],
|
||||
// );
|
||||
// }
|
||||
|
||||
factory Feature.fromMap(Map<String, dynamic> map) {
|
||||
Geometry? geometry = map['geometry'] != null
|
||||
? Geometry.fromMap(map['geometry'])
|
||||
: null;
|
||||
double? latitude = geometry?.coordinates?.isNotEmpty ?? false ? geometry!.coordinates![0][0] : null;
|
||||
double? longitude = geometry?.coordinates?.isNotEmpty ?? false ? geometry!.coordinates![0][1] : null;
|
||||
|
||||
return Feature(
|
||||
id: map['id'] as int?,
|
||||
geometry: Geometry.fromMap(map['geometry']),
|
||||
properties: Properties.fromMap(map['properties']),
|
||||
type: map['type'],
|
||||
location_id: Properties.fromMap(map['properties']).location_id,
|
||||
latitude: latitude,
|
||||
longitude: longitude,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory Feature.fromJson(String source) =>
|
||||
Feature.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Feature(geometry: $geometry, id: $id, properties: $properties, type: $type)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is Feature &&
|
||||
other.geometry == geometry &&
|
||||
other.id == id &&
|
||||
other.properties == properties &&
|
||||
other.type == type;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return geometry.hashCode ^ id.hashCode ^ properties.hashCode ^ type.hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
class Geometry {
|
||||
List<List<double>>? coordinates;
|
||||
String? type;
|
||||
|
||||
Geometry({
|
||||
this.coordinates,
|
||||
this.type,
|
||||
});
|
||||
|
||||
Geometry copyWith({
|
||||
List<List<double>>? coordinates,
|
||||
String? type,
|
||||
}) {
|
||||
return Geometry(
|
||||
coordinates: coordinates ?? this.coordinates,
|
||||
type: type ?? this.type,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'coordinates': coordinates,
|
||||
'type': type,
|
||||
};
|
||||
}
|
||||
|
||||
factory Geometry.fromMap(Map<String, dynamic> map) {
|
||||
return Geometry(
|
||||
coordinates: map['coordinates'] != null
|
||||
? List<List<double>>.from(
|
||||
map['coordinates'].map((x) => List<double>.from(x.map((x) => x.toDouble()))))
|
||||
: null,
|
||||
type: map['type'],
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory Geometry.fromJson(String source) =>
|
||||
Geometry.fromMap(json.decode(source) as Map<String, dynamic>);
|
||||
|
||||
@override
|
||||
String toString() => 'Geometry(coordinates: $coordinates, type: $type)';
|
||||
|
||||
@override
|
||||
bool operator ==(covariant Geometry other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return listEquals(other.coordinates, coordinates) && other.type == type;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => coordinates.hashCode ^ type.hashCode;
|
||||
}
|
||||
|
||||
class Properties {
|
||||
final int location_id;
|
||||
final String? sub_loc_id;
|
||||
final double? cp;
|
||||
final String? location_name;
|
||||
final String? category;
|
||||
final String? subcategory;
|
||||
final String? zip;
|
||||
final String? address;
|
||||
final String? prefecture;
|
||||
final String? area;
|
||||
final String? city;
|
||||
final double? latitude;
|
||||
final double? longitude;
|
||||
final String? photos;
|
||||
final String? videos;
|
||||
final String? webcontents;
|
||||
final String? status;
|
||||
final String? portal;
|
||||
final String? group;
|
||||
final String? phone;
|
||||
final String? fax;
|
||||
final String? email;
|
||||
final String? facility;
|
||||
final String? remark;
|
||||
final String? tags;
|
||||
final dynamic? event_name;
|
||||
final bool? event_active;
|
||||
final bool? hidden_location;
|
||||
final bool? auto_checkin;
|
||||
final double? checkin_radius;
|
||||
final double? checkin_point;
|
||||
final double? buy_point;
|
||||
final String? evaluation_value;
|
||||
final bool? shop_closed;
|
||||
final bool? shop_shutdown;
|
||||
final String? opening_hours_mon;
|
||||
final String? opening_hours_tue;
|
||||
final String? opening_hours_wed;
|
||||
final String? opening_hours_thu;
|
||||
final String? opening_hours_fri;
|
||||
final String? opening_hours_sat;
|
||||
final String? opening_hours_sun;
|
||||
final String? parammeters;
|
||||
Properties({
|
||||
required this.location_id,
|
||||
this.sub_loc_id,
|
||||
this.cp,
|
||||
this.location_name,
|
||||
this.category,
|
||||
this.subcategory,
|
||||
this.zip,
|
||||
this.address,
|
||||
this.prefecture,
|
||||
this.area,
|
||||
this.city,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
this.photos,
|
||||
this.videos,
|
||||
this.webcontents,
|
||||
this.status,
|
||||
this.portal,
|
||||
this.group,
|
||||
this.phone,
|
||||
this.fax,
|
||||
this.email,
|
||||
this.facility,
|
||||
this.remark,
|
||||
this.tags,
|
||||
this.event_name,
|
||||
this.event_active,
|
||||
this.hidden_location,
|
||||
this.auto_checkin,
|
||||
this.checkin_radius,
|
||||
this.checkin_point,
|
||||
this.buy_point,
|
||||
this.evaluation_value,
|
||||
this.shop_closed,
|
||||
this.shop_shutdown,
|
||||
this.opening_hours_mon,
|
||||
this.opening_hours_tue,
|
||||
this.opening_hours_wed,
|
||||
this.opening_hours_thu,
|
||||
this.opening_hours_fri,
|
||||
this.opening_hours_sat,
|
||||
this.opening_hours_sun,
|
||||
this.parammeters,
|
||||
});
|
||||
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
Properties copyWith({
|
||||
int? location_id,
|
||||
String? sub_loc_id,
|
||||
double? cp,
|
||||
String? location_name,
|
||||
String? category,
|
||||
String? subcategory,
|
||||
String? zip,
|
||||
String? address,
|
||||
String? prefecture,
|
||||
String? area,
|
||||
String? city,
|
||||
double? latitude,
|
||||
double? longitude,
|
||||
String? photos,
|
||||
String? videos,
|
||||
String? webcontents,
|
||||
String? status,
|
||||
String? portal,
|
||||
String? group,
|
||||
String? phone,
|
||||
String? fax,
|
||||
String? email,
|
||||
String? facility,
|
||||
String? remark,
|
||||
String? tags,
|
||||
dynamic? event_name,
|
||||
bool? event_active,
|
||||
bool? hidden_location,
|
||||
bool? auto_checkin,
|
||||
double? checkin_radius,
|
||||
double? checkin_point,
|
||||
double? buy_point,
|
||||
String? evaluation_value,
|
||||
bool? shop_closed,
|
||||
bool? shop_shutdown,
|
||||
String? opening_hours_mon,
|
||||
String? opening_hours_tue,
|
||||
String? opening_hours_wed,
|
||||
String? opening_hours_thu,
|
||||
String? opening_hours_fri,
|
||||
String? opening_hours_sat,
|
||||
String? opening_hours_sun,
|
||||
String? parammeters,
|
||||
}) {
|
||||
return Properties(
|
||||
location_id: location_id ?? this.location_id,
|
||||
sub_loc_id: sub_loc_id ?? this.sub_loc_id,
|
||||
cp: cp ?? this.cp,
|
||||
location_name: location_name ?? this.location_name,
|
||||
category: category ?? this.category,
|
||||
subcategory: subcategory ?? this.subcategory,
|
||||
zip: zip ?? this.zip,
|
||||
address: address ?? this.address,
|
||||
prefecture: prefecture ?? this.prefecture,
|
||||
area: area ?? this.area,
|
||||
city: city ?? this.city,
|
||||
latitude: latitude ?? this.latitude,
|
||||
longitude: longitude ?? this.longitude,
|
||||
photos: photos ?? this.photos,
|
||||
videos: videos ?? this.videos,
|
||||
webcontents: webcontents ?? this.webcontents,
|
||||
status: status ?? this.status,
|
||||
portal: portal ?? this.portal,
|
||||
group: group ?? this.group,
|
||||
phone: phone ?? this.phone,
|
||||
fax: fax ?? this.fax,
|
||||
email: email ?? this.email,
|
||||
facility: facility ?? this.facility,
|
||||
remark: remark ?? this.remark,
|
||||
tags: tags ?? this.tags,
|
||||
event_name: event_name ?? this.event_name,
|
||||
event_active: event_active ?? this.event_active,
|
||||
hidden_location: hidden_location ?? this.hidden_location,
|
||||
auto_checkin: auto_checkin ?? this.auto_checkin,
|
||||
checkin_radius: checkin_radius ?? this.checkin_radius,
|
||||
checkin_point: checkin_point ?? this.checkin_point,
|
||||
buy_point: buy_point ?? this.buy_point,
|
||||
evaluation_value: evaluation_value ?? this.evaluation_value,
|
||||
shop_closed: shop_closed ?? this.shop_closed,
|
||||
shop_shutdown: shop_shutdown ?? this.shop_shutdown,
|
||||
opening_hours_mon: opening_hours_mon ?? this.opening_hours_mon,
|
||||
opening_hours_tue: opening_hours_tue ?? this.opening_hours_tue,
|
||||
opening_hours_wed: opening_hours_wed ?? this.opening_hours_wed,
|
||||
opening_hours_thu: opening_hours_thu ?? this.opening_hours_thu,
|
||||
opening_hours_fri: opening_hours_fri ?? this.opening_hours_fri,
|
||||
opening_hours_sat: opening_hours_sat ?? this.opening_hours_sat,
|
||||
opening_hours_sun: opening_hours_sun ?? this.opening_hours_sun,
|
||||
parammeters: parammeters ?? this.parammeters,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return <String, dynamic>{
|
||||
'location_id': location_id,
|
||||
'sub_loc_id': sub_loc_id,
|
||||
'cp': cp,
|
||||
'location_name': location_name,
|
||||
'category': category,
|
||||
'subcategory': subcategory,
|
||||
'zip': zip,
|
||||
'address': address,
|
||||
'prefecture': prefecture,
|
||||
'area': area,
|
||||
'city': city,
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'photos': photos,
|
||||
'videos': videos,
|
||||
'webcontents': webcontents,
|
||||
'status': status,
|
||||
'portal': portal,
|
||||
'group': group,
|
||||
'phone': phone,
|
||||
'fax': fax,
|
||||
'email': email,
|
||||
'facility': facility,
|
||||
'remark': remark,
|
||||
'tags': tags,
|
||||
'event_name': event_name,
|
||||
'event_active': event_active,
|
||||
'hidden_location': hidden_location,
|
||||
'auto_checkin': auto_checkin,
|
||||
'checkin_radius': checkin_radius,
|
||||
'checkin_point': checkin_point,
|
||||
'buy_point': buy_point,
|
||||
'evaluation_value': evaluation_value,
|
||||
'shop_closed': shop_closed,
|
||||
'shop_shutdown': shop_shutdown,
|
||||
'opening_hours_mon': opening_hours_mon,
|
||||
'opening_hours_tue': opening_hours_tue,
|
||||
'opening_hours_wed': opening_hours_wed,
|
||||
'opening_hours_thu': opening_hours_thu,
|
||||
'opening_hours_fri': opening_hours_fri,
|
||||
'opening_hours_sat': opening_hours_sat,
|
||||
'opening_hours_sun': opening_hours_sun,
|
||||
'parammeters': parammeters,
|
||||
};
|
||||
}
|
||||
|
||||
factory Properties.fromMap(Map<String, dynamic> map) {
|
||||
return Properties(
|
||||
location_id: map['location_id'] as int,
|
||||
sub_loc_id: map['sub_loc_id'] != null ? map['sub_loc_id'] as String : null,
|
||||
cp: map['cp'] != null ? map['cp'] as double : null,
|
||||
location_name: map['location_name'] != null ? map['location_name'] as String : null,
|
||||
category: map['category'] != null ? map['category'] as String : null,
|
||||
subcategory: map['subcategory'] != null ? map['subcategory'] as String : null,
|
||||
zip: map['zip'] != null ? map['zip'] as String : null,
|
||||
address: map['address'] != null ? map['address'] as String : null,
|
||||
prefecture: map['prefecture'] != null ? map['prefecture'] as String : null,
|
||||
area: map['area'] != null ? map['area'] as String : null,
|
||||
city: map['city'] != null ? map['city'] as String : null,
|
||||
latitude: map['latitude'] != null ? map['latitude'] as double : null,
|
||||
longitude: map['longitude'] != null ? map['longitude'] as double : null,
|
||||
photos: map['photos'] != null ? map['photos'] as String : null,
|
||||
videos: map['videos'] != null ? map['videos'] as String : null,
|
||||
webcontents: map['webcontents'] != null ? map['webcontents'] as String : null,
|
||||
status: map['status'] != null ? map['status'] as String : null,
|
||||
portal: map['portal'] != null ? map['portal'] as String : null,
|
||||
group: map['group'] != null ? map['group'] as String : null,
|
||||
phone: map['phone'] != null ? map['phone'] as String : null,
|
||||
fax: map['fax'] != null ? map['fax'] as String : null,
|
||||
email: map['email'] != null ? map['email'] as String : null,
|
||||
facility: map['facility'] != null ? map['facility'] as String : null,
|
||||
remark: map['remark'] != null ? map['remark'] as String : null,
|
||||
tags: map['tags'] != null ? map['tags'] as String : null,
|
||||
event_name: map['event_name'] != null ? map['event_name'] as dynamic : null,
|
||||
event_active: map['event_active'] != null ? map['event_active'] as bool : null,
|
||||
hidden_location: map['hidden_location'] != null ? map['hidden_location'] as bool : null,
|
||||
auto_checkin: map['auto_checkin'] != null ? map['auto_checkin'] as bool : null,
|
||||
checkin_radius: map['checkin_radius'] != null ? map['checkin_radius'] as double : null,
|
||||
checkin_point: map['checkin_point'] != null ? map['checkin_point'] as double : null,
|
||||
buy_point: map['buy_point'] != null ? map['buy_point'] as double : null,
|
||||
evaluation_value: map['evaluation_value'] != null ? map['evaluation_value'] as String : null,
|
||||
shop_closed: map['shop_closed'] != null ? map['shop_closed'] as bool : null,
|
||||
shop_shutdown: map['shop_shutdown'] != null ? map['shop_shutdown'] as bool : null,
|
||||
opening_hours_mon: map['opening_hours_mon'] != null ? map['opening_hours_mon'] as String : null,
|
||||
opening_hours_tue: map['opening_hours_tue'] != null ? map['opening_hours_tue'] as String : null,
|
||||
opening_hours_wed: map['opening_hours_wed'] != null ? map['opening_hours_wed'] as String : null,
|
||||
opening_hours_thu: map['opening_hours_thu'] != null ? map['opening_hours_thu'] as String : null,
|
||||
opening_hours_fri: map['opening_hours_fri'] != null ? map['opening_hours_fri'] as String : null,
|
||||
opening_hours_sat: map['opening_hours_sat'] != null ? map['opening_hours_sat'] as String : null,
|
||||
opening_hours_sun: map['opening_hours_sun'] != null ? map['opening_hours_sun'] as String : null,
|
||||
parammeters: map['parammeters'] != null ? map['parammeters'] as String : null,
|
||||
);
|
||||
}
|
||||
|
||||
factory Properties.fromJson(String source) => Properties.fromMap(json.decode(source) as Map<String, dynamic>);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Properties(location_id: $location_id, sub_loc_id: $sub_loc_id, cp: $cp, location_name: $location_name, category: $category, subcategory: $subcategory, zip: $zip, address: $address, prefecture: $prefecture, area: $area, city: $city, latitude: $latitude, longitude: $longitude, photos: $photos, videos: $videos, webcontents: $webcontents, status: $status, portal: $portal, group: $group, phone: $phone, fax: $fax, email: $email, facility: $facility, remark: $remark, tags: $tags, event_name: $event_name, event_active: $event_active, hidden_location: $hidden_location, auto_checkin: $auto_checkin, checkin_radius: $checkin_radius, checkin_point: $checkin_point, buy_point: $buy_point, evaluation_value: $evaluation_value, shop_closed: $shop_closed, shop_shutdown: $shop_shutdown, opening_hours_mon: $opening_hours_mon, opening_hours_tue: $opening_hours_tue, opening_hours_wed: $opening_hours_wed, opening_hours_thu: $opening_hours_thu, opening_hours_fri: $opening_hours_fri, opening_hours_sat: $opening_hours_sat, opening_hours_sun: $opening_hours_sun, parammeters: $parammeters)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(covariant Properties other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return
|
||||
other.location_id == location_id &&
|
||||
other.sub_loc_id == sub_loc_id &&
|
||||
other.cp == cp &&
|
||||
other.location_name == location_name &&
|
||||
other.category == category &&
|
||||
other.subcategory == subcategory &&
|
||||
other.zip == zip &&
|
||||
other.address == address &&
|
||||
other.prefecture == prefecture &&
|
||||
other.area == area &&
|
||||
other.city == city &&
|
||||
other.latitude == latitude &&
|
||||
other.longitude == longitude &&
|
||||
other.photos == photos &&
|
||||
other.videos == videos &&
|
||||
other.webcontents == webcontents &&
|
||||
other.status == status &&
|
||||
other.portal == portal &&
|
||||
other.group == group &&
|
||||
other.phone == phone &&
|
||||
other.fax == fax &&
|
||||
other.email == email &&
|
||||
other.facility == facility &&
|
||||
other.remark == remark &&
|
||||
other.tags == tags &&
|
||||
other.event_name == event_name &&
|
||||
other.event_active == event_active &&
|
||||
other.hidden_location == hidden_location &&
|
||||
other.auto_checkin == auto_checkin &&
|
||||
other.checkin_radius == checkin_radius &&
|
||||
other.checkin_point == checkin_point &&
|
||||
other.buy_point == buy_point &&
|
||||
other.evaluation_value == evaluation_value &&
|
||||
other.shop_closed == shop_closed &&
|
||||
other.shop_shutdown == shop_shutdown &&
|
||||
other.opening_hours_mon == opening_hours_mon &&
|
||||
other.opening_hours_tue == opening_hours_tue &&
|
||||
other.opening_hours_wed == opening_hours_wed &&
|
||||
other.opening_hours_thu == opening_hours_thu &&
|
||||
other.opening_hours_fri == opening_hours_fri &&
|
||||
other.opening_hours_sat == opening_hours_sat &&
|
||||
other.opening_hours_sun == opening_hours_sun &&
|
||||
other.parammeters == parammeters;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return location_id.hashCode ^
|
||||
sub_loc_id.hashCode ^
|
||||
cp.hashCode ^
|
||||
location_name.hashCode ^
|
||||
category.hashCode ^
|
||||
subcategory.hashCode ^
|
||||
zip.hashCode ^
|
||||
address.hashCode ^
|
||||
prefecture.hashCode ^
|
||||
area.hashCode ^
|
||||
city.hashCode ^
|
||||
latitude.hashCode ^
|
||||
longitude.hashCode ^
|
||||
photos.hashCode ^
|
||||
videos.hashCode ^
|
||||
webcontents.hashCode ^
|
||||
status.hashCode ^
|
||||
portal.hashCode ^
|
||||
group.hashCode ^
|
||||
phone.hashCode ^
|
||||
fax.hashCode ^
|
||||
email.hashCode ^
|
||||
facility.hashCode ^
|
||||
remark.hashCode ^
|
||||
tags.hashCode ^
|
||||
event_name.hashCode ^
|
||||
event_active.hashCode ^
|
||||
hidden_location.hashCode ^
|
||||
auto_checkin.hashCode ^
|
||||
checkin_radius.hashCode ^
|
||||
checkin_point.hashCode ^
|
||||
buy_point.hashCode ^
|
||||
evaluation_value.hashCode ^
|
||||
shop_closed.hashCode ^
|
||||
shop_shutdown.hashCode ^
|
||||
opening_hours_mon.hashCode ^
|
||||
opening_hours_tue.hashCode ^
|
||||
opening_hours_wed.hashCode ^
|
||||
opening_hours_thu.hashCode ^
|
||||
opening_hours_fri.hashCode ^
|
||||
opening_hours_sat.hashCode ^
|
||||
opening_hours_sun.hashCode ^
|
||||
parammeters.hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
45
lib/model/user.dart
Normal file
45
lib/model/user.dart
Normal file
@ -0,0 +1,45 @@
|
||||
class AuthResponse {
|
||||
final User user;
|
||||
final String token;
|
||||
|
||||
AuthResponse({required this.user, required this.token});
|
||||
|
||||
factory AuthResponse.fromJson(Map<String, dynamic> json) {
|
||||
return AuthResponse(
|
||||
user: User.fromJson(json['user']),
|
||||
token: json['token'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class User {
|
||||
final int id;
|
||||
final String email;
|
||||
final bool isRogaining;
|
||||
final String group;
|
||||
final String zekkenNumber;
|
||||
final String eventCode;
|
||||
final String teamName;
|
||||
|
||||
User({
|
||||
required this.id,
|
||||
required this.email,
|
||||
required this.isRogaining,
|
||||
required this.group,
|
||||
required this.zekkenNumber,
|
||||
required this.eventCode,
|
||||
required this.teamName,
|
||||
});
|
||||
|
||||
factory User.fromJson(Map<String, dynamic> json) {
|
||||
return User(
|
||||
id: json['id'],
|
||||
email: json['email'],
|
||||
isRogaining: json['is_rogaining'],
|
||||
group: json['group'],
|
||||
zekkenNumber: json['zekken_number'],
|
||||
eventCode: json['event_code'],
|
||||
teamName: json['team_name'],
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -4,12 +4,13 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/model/location_response.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/services/external_service.dart';
|
||||
|
||||
class CameraPage extends StatelessWidget {
|
||||
Destination? destination;
|
||||
Feature? destination;
|
||||
CameraPage({Key? key, this.destination}) : super(key: key);
|
||||
DestinationController destinationController = Get.find<DestinationController>();
|
||||
IndexController indexController = Get.find<IndexController>();
|
||||
@ -135,7 +136,7 @@ class CameraPage extends StatelessWidget {
|
||||
appBar:
|
||||
destinationController.is_in_rog.value && destinationController.rogaining_counted.value == true ?
|
||||
AppBar(
|
||||
title: destination!.cp == -1 ?
|
||||
title: destination!.properties!.cp == -1 ?
|
||||
Text("finishing_rogaining".tr)
|
||||
:
|
||||
Text("cp_pls_take_photo".tr)
|
||||
|
||||
@ -221,14 +221,14 @@ class DestinationController extends GetxController {
|
||||
chekcs = 3;
|
||||
is_in_checkin.value = true;
|
||||
photos.clear();
|
||||
showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
builder:((context) => CameraPage(destination: d,))
|
||||
).whenComplete((){
|
||||
skip_gps = false;
|
||||
rogaining_counted.value =true;
|
||||
chekcs = 0;
|
||||
is_in_checkin.value = false;
|
||||
});
|
||||
// showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
// builder:((context) => CameraPage(destination: d,))
|
||||
// ).whenComplete((){
|
||||
// skip_gps = false;
|
||||
// rogaining_counted.value =true;
|
||||
// chekcs = 0;
|
||||
// is_in_checkin.value = false;
|
||||
// });
|
||||
}
|
||||
else if(is_in_rog.value == true && d.cp != -1){
|
||||
chekcs = 4;
|
||||
@ -267,13 +267,13 @@ class DestinationController extends GetxController {
|
||||
chekcs = 5;
|
||||
is_at_goal.value = true;
|
||||
photos.clear();
|
||||
showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
builder:((context) => CameraPage(destination: d,))
|
||||
).whenComplete((){
|
||||
skip_gps = false;
|
||||
chekcs = 0;
|
||||
is_at_goal.value = false;
|
||||
});
|
||||
// showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
// builder:((context) => CameraPage(destination: d,))
|
||||
// ).whenComplete((){
|
||||
// skip_gps = false;
|
||||
// chekcs = 0;
|
||||
// is_at_goal.value = false;
|
||||
// });
|
||||
}
|
||||
else if(is_in_rog.value == false && indexController.rog_mode == 1 && DateTime.now().difference(last_goal_at).inHours >= 24){
|
||||
//start
|
||||
|
||||
@ -91,7 +91,7 @@ class DestinationMapPage extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
Container( color: Colors.yellow, child: Text(TextUtils.getDisplayText(d), style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold, overflow: TextOverflow.visible),)),
|
||||
//Container( color: Colors.yellow, child: Text(TextUtils.getDisplayText(d), style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold, overflow: TextOverflow.visible),)),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
|
||||
class PermissionHandlerScreen extends StatefulWidget {
|
||||
PermissionHandlerScreen({Key? key}) : super(key: key);
|
||||
const PermissionHandlerScreen({super.key});
|
||||
|
||||
@override
|
||||
State<PermissionHandlerScreen> createState() => _PermissionHandlerScreenState();
|
||||
@ -12,145 +14,220 @@ class PermissionHandlerScreen extends StatefulWidget {
|
||||
|
||||
class _PermissionHandlerScreenState extends State<PermissionHandlerScreen> {
|
||||
|
||||
|
||||
Future<void> _showMyDialog() async {
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false, // user must tap button!
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('ロケーション許可'),
|
||||
content: SingleChildScrollView(
|
||||
child: ListBody(
|
||||
children: const <Widget>[
|
||||
Text( 'このアプリでは、位置情報の収集を行います。'),
|
||||
Text( 'このアプリでは、開始時点で位置情報を収集します。'),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('わかった'),
|
||||
onPressed: () {
|
||||
//Navigator.of(context).pop();
|
||||
Get.toNamed(AppPages.TRAVEL);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
void initState(){
|
||||
super.initState();
|
||||
|
||||
//permissionServiceCall();
|
||||
_checkPermissions();
|
||||
}
|
||||
|
||||
Future<PermissionStatus> checkLocationPermission() async {
|
||||
return await Permission.location.status;
|
||||
}
|
||||
void _checkPermissions() async {
|
||||
// You can ask for multiple permissions at once.
|
||||
Map<Permission, PermissionStatus> statuses = await [
|
||||
Permission.location,
|
||||
Permission.camera,
|
||||
].request();
|
||||
|
||||
permissionServiceCall() async {
|
||||
await permissionServices().then(
|
||||
(value) {
|
||||
if (value != null) {
|
||||
if (value[Permission.location]!.isGranted ) {
|
||||
/* ========= New Screen Added ============= */
|
||||
bool isCameraGranted = statuses[Permission.camera]!.isGranted;
|
||||
bool isLocationGranted = statuses[Permission.location]!.isGranted;
|
||||
|
||||
Get.toNamed(AppPages.TRAVEL);
|
||||
if (!isCameraGranted || !isLocationGranted) {
|
||||
bool isCameraPermanentlyDenied = statuses[Permission.camera]!.isPermanentlyDenied;
|
||||
bool isLocationPermanentlyDenied = statuses[Permission.location]!.isPermanentlyDenied;
|
||||
|
||||
// Navigator.pushReplacement(
|
||||
// context,
|
||||
// MaterialPageRoute(builder: (context) => SplashScreen()),
|
||||
// );
|
||||
}
|
||||
else{
|
||||
_showMyDialog();
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/*Permission services*/
|
||||
Future<Map<Permission, PermissionStatus>> permissionServices() async {
|
||||
// You can request multiple permissions at once.
|
||||
Map<Permission, PermissionStatus> statuses = await [
|
||||
Permission.location,
|
||||
|
||||
//add more permission to request here.
|
||||
].request();
|
||||
|
||||
if (statuses[Permission.location]!.isPermanentlyDenied) {
|
||||
await openAppSettings().then(
|
||||
(value) async {
|
||||
if (value) {
|
||||
if (await Permission.location.status.isPermanentlyDenied == true &&
|
||||
await Permission.location.status.isGranted == false) {
|
||||
// openAppSettings();
|
||||
permissionServiceCall(); /* opens app settings until permission is granted */
|
||||
}
|
||||
}
|
||||
if (isCameraPermanentlyDenied || isLocationPermanentlyDenied) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Permissions not granted'),
|
||||
content: const Text(
|
||||
'This app needs camera and location permissions to function. Please open settings and grant permissions.'),
|
||||
actions: <Widget>[
|
||||
ElevatedButton(
|
||||
child: const Text('Open settings'),
|
||||
onPressed: () {
|
||||
openAppSettings();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
if (statuses[Permission.location]!.isDenied) {
|
||||
permissionServiceCall();
|
||||
}
|
||||
// ask permissions again
|
||||
_checkPermissions();
|
||||
}
|
||||
|
||||
/*{Permission.camera: PermissionStatus.granted, Permission.storage: PermissionStatus.granted}*/
|
||||
return statuses;
|
||||
} else {
|
||||
Get.toNamed(AppPages.INITIAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var status = Permission.location.status.then((value){
|
||||
if(value.isGranted == false){
|
||||
Future.delayed(Duration.zero, () => showAlert(context));
|
||||
}
|
||||
else {
|
||||
Get.toNamed(AppPages.TRAVEL);
|
||||
}
|
||||
});
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
child: Text(""),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showAlert(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
title: const Text('ロケーション許可'),
|
||||
content: SingleChildScrollView(
|
||||
child: ListBody(
|
||||
children: const <Widget>[
|
||||
Text( 'このアプリでは、位置情報の収集を行います。'),
|
||||
Text('岐阜ナビアプリではチェックポイントの自動チェックインの機能を可能にするために、現在地のデータが収集されます。アプリを閉じている時や、使用していないときにも収集されます。位置情報は、個人を特定できない統計的な情報として、ユーザーの個人情報とは一切結びつかない形で送信されます。お知らせの配信、位置情報の利用を許可しない場合は、この後表示されるダイアログで「許可しない」を選択してください。'),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('わかった'),
|
||||
onPressed: () {
|
||||
permissionServiceCall();
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
return const Scaffold(
|
||||
body: Center(
|
||||
child: Text('Checking permissions...'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:get/get.dart';
|
||||
// import 'package:permission_handler/permission_handler.dart';
|
||||
// import 'package:rogapp/routes/app_pages.dart';
|
||||
|
||||
// class PermissionHandlerScreen extends StatefulWidget {
|
||||
// PermissionHandlerScreen({Key? key}) : super(key: key);
|
||||
|
||||
// @override
|
||||
// State<PermissionHandlerScreen> createState() => _PermissionHandlerScreenState();
|
||||
// }
|
||||
|
||||
// class _PermissionHandlerScreenState extends State<PermissionHandlerScreen> {
|
||||
|
||||
|
||||
// Future<void> _showMyDialog() async {
|
||||
// return showDialog<void>(
|
||||
// context: context,
|
||||
// barrierDismissible: false, // user must tap button!
|
||||
// builder: (BuildContext context) {
|
||||
// return AlertDialog(
|
||||
// title: const Text('ロケーション許可'),
|
||||
// content: SingleChildScrollView(
|
||||
// child: ListBody(
|
||||
// children: const <Widget>[
|
||||
// Text( 'このアプリでは、位置情報の収集を行います。'),
|
||||
// Text( 'このアプリでは、開始時点で位置情報を収集します。'),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// actions: <Widget>[
|
||||
// TextButton(
|
||||
// child: const Text('わかった'),
|
||||
// onPressed: () {
|
||||
// //Navigator.of(context).pop();
|
||||
// Get.toNamed(AppPages.TRAVEL);
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
|
||||
// @override
|
||||
// void initState() {
|
||||
// // TODO: implement initState
|
||||
// super.initState();
|
||||
|
||||
// //permissionServiceCall();
|
||||
// }
|
||||
|
||||
// Future<PermissionStatus> checkLocationPermission() async {
|
||||
// return await Permission.location.status;
|
||||
// }
|
||||
|
||||
// permissionServiceCall() async {
|
||||
// await permissionServices().then(
|
||||
// (value) {
|
||||
// if (value != null) {
|
||||
// if (value[Permission.location]!.isGranted ) {
|
||||
// /* ========= New Screen Added ============= */
|
||||
|
||||
// Get.toNamed(AppPages.TRAVEL);
|
||||
|
||||
// // Navigator.pushReplacement(
|
||||
// // context,
|
||||
// // MaterialPageRoute(builder: (context) => SplashScreen()),
|
||||
// // );
|
||||
// }
|
||||
// else{
|
||||
// _showMyDialog();
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
// /*Permission services*/
|
||||
// Future<Map<Permission, PermissionStatus>> permissionServices() async {
|
||||
// // You can request multiple permissions at once.
|
||||
// Map<Permission, PermissionStatus> statuses = await [
|
||||
// Permission.location,
|
||||
|
||||
// //add more permission to request here.
|
||||
// ].request();
|
||||
|
||||
// if (statuses[Permission.location]!.isPermanentlyDenied) {
|
||||
// await openAppSettings().then(
|
||||
// (value) async {
|
||||
// if (value) {
|
||||
// if (await Permission.location.status.isPermanentlyDenied == true &&
|
||||
// await Permission.location.status.isGranted == false) {
|
||||
// // openAppSettings();
|
||||
// permissionServiceCall(); /* opens app settings until permission is granted */
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// );
|
||||
// } else {
|
||||
// if (statuses[Permission.location]!.isDenied) {
|
||||
// permissionServiceCall();
|
||||
// }
|
||||
// }
|
||||
|
||||
// /*{Permission.camera: PermissionStatus.granted, Permission.storage: PermissionStatus.granted}*/
|
||||
// return statuses;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// var status = Permission.location.status.then((value){
|
||||
// if(value.isGranted == false){
|
||||
// Future.delayed(Duration.zero, () => showAlert(context));
|
||||
// }
|
||||
// else {
|
||||
// Get.toNamed(AppPages.TRAVEL);
|
||||
// }
|
||||
// });
|
||||
// return Scaffold(
|
||||
// body: Container(
|
||||
// child: Text(""),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
// void showAlert(BuildContext context) {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (_) => AlertDialog(
|
||||
// title: const Text('ロケーション許可'),
|
||||
// content: SingleChildScrollView(
|
||||
// child: ListBody(
|
||||
// children: const <Widget>[
|
||||
// Text( 'このアプリでは、位置情報の収集を行います。'),
|
||||
// Text('岐阜ナビアプリではチェックポイントの自動チェックインの機能を可能にするために、現在地のデータが収集されます。アプリを閉じている時や、使用していないときにも収集されます。位置情報は、個人を特定できない統計的な情報として、ユーザーの個人情報とは一切結びつかない形で送信されます。お知らせの配信、位置情報の利用を許可しない場合は、この後表示されるダイアログで「許可しない」を選択してください。'),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// actions: <Widget>[
|
||||
// TextButton(
|
||||
// child: const Text('わかった'),
|
||||
// onPressed: () {
|
||||
// permissionServiceCall();
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// )
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
@ -6,7 +6,6 @@ import 'package:rogapp/pages/changepassword/change_password_page.dart';
|
||||
import 'package:rogapp/pages/city/city_page.dart';
|
||||
import 'package:rogapp/pages/destination/destination_binding.dart';
|
||||
import 'package:rogapp/pages/destination/destination_page.dart';
|
||||
import 'package:rogapp/pages/home/home_binding.dart';
|
||||
import 'package:rogapp/pages/home/home_page.dart';
|
||||
|
||||
import 'package:rogapp/pages/index/index_page.dart';
|
||||
@ -20,14 +19,23 @@ import 'package:rogapp/pages/register/register_page.dart';
|
||||
import 'package:rogapp/pages/search/search_binding.dart';
|
||||
import 'package:rogapp/pages/search/search_page.dart';
|
||||
import 'package:rogapp/pages/subperf/subperf_page.dart';
|
||||
import 'package:rogapp/screens/auth/views/login/login_screen.dart';
|
||||
import 'package:rogapp/screens/auth/views/register/register_screen.dart';
|
||||
import 'package:rogapp/screens/home/home_screen.dart';
|
||||
import 'package:rogapp/spa/spa_binding.dart';
|
||||
import 'package:rogapp/spa/spa_page.dart';
|
||||
|
||||
import '../screens/home/home_binding.dart';
|
||||
|
||||
|
||||
part 'app_routes.dart';
|
||||
|
||||
class AppPages {
|
||||
|
||||
static const S_HOME = Routes.S_HOME;
|
||||
static const S_LOGIN = Routes.S_LOGIN;
|
||||
static const S_REGISTER= Routes.S_REGISTER;
|
||||
|
||||
// ignore: constant_identifier_names
|
||||
static const INITIAL = Routes.INDEX;
|
||||
// ignore: constant_identifier_names
|
||||
@ -60,6 +68,20 @@ class AppPages {
|
||||
// page: () => MapPage(),
|
||||
// binding: MapBinding(),
|
||||
// )
|
||||
GetPage(
|
||||
name: Routes.S_HOME,
|
||||
page: () => HomeScreen(),
|
||||
binding: HomeBinding()
|
||||
),
|
||||
GetPage(
|
||||
name: Routes.S_LOGIN,
|
||||
page: () => LoginScreen(),
|
||||
//binding: IndexBinding(),
|
||||
),
|
||||
GetPage(
|
||||
name: Routes.S_REGISTER,
|
||||
page: () => RegisterScreen(),
|
||||
),
|
||||
GetPage(
|
||||
name: Routes.INDEX,
|
||||
page: () => IndexPage(),
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
part of 'app_pages.dart';
|
||||
|
||||
abstract class Routes {
|
||||
static const S_HOME = '/s_home';
|
||||
static const S_LOGIN = '/s_login';
|
||||
static const S_REGISTER = '/s_register';
|
||||
// Main Menu Route
|
||||
// static const HOME = '/';
|
||||
// static const MAP = '/map';
|
||||
|
||||
36
lib/screens/auth/common/uis/auth_text_field.dart
Normal file
36
lib/screens/auth/common/uis/auth_text_field.dart
Normal file
@ -0,0 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rogapp/theme/pallete.dart';
|
||||
|
||||
class AuthTextField extends StatelessWidget {
|
||||
final TextEditingController controller;
|
||||
final String hinttext;
|
||||
final bool isObsque;
|
||||
const AuthTextField({super.key, required this.controller, required this.hinttext, this.isObsque = false});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextFormField(
|
||||
controller: controller,
|
||||
decoration: InputDecoration(
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
borderSide: const BorderSide(
|
||||
color: Pallete.BLUE_COLOR,
|
||||
width: 2
|
||||
)
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
borderSide: const BorderSide(
|
||||
color: Pallete.BROWN_COLOR,
|
||||
)
|
||||
),
|
||||
contentPadding: const EdgeInsets.all(22),
|
||||
hintText: hinttext,
|
||||
hintStyle: const TextStyle(
|
||||
fontSize: 18,
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
30
lib/screens/auth/common/uis/rounded_small_button.dart
Normal file
30
lib/screens/auth/common/uis/rounded_small_button.dart
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
import 'package:rogapp/theme/theme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class RoundedSmallButton extends StatelessWidget {
|
||||
final VoidCallback onTap;
|
||||
final String label;
|
||||
final Color backgroundColor;
|
||||
final Color textColor;
|
||||
|
||||
const RoundedSmallButton({
|
||||
super.key,
|
||||
required this.onTap,
|
||||
required this.label,
|
||||
this.backgroundColor = Pallete.WHITE_COLOR,
|
||||
this.textColor = Pallete.BACKGROUND_COLOR,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
child: Chip(
|
||||
label: Text(label, style: TextStyle(color: textColor, fontSize: 16),),
|
||||
backgroundColor: backgroundColor,
|
||||
labelPadding:const EdgeInsets.symmetric(horizontal: 10, vertical: 3),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
45
lib/screens/auth/controller/auth_controller.dart
Normal file
45
lib/screens/auth/controller/auth_controller.dart
Normal file
@ -0,0 +1,45 @@
|
||||
import 'dart:convert' as convert;
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/model/user.dart';
|
||||
import 'package:rogapp/utils/const.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class AuthController extends GetxController{
|
||||
var isLoading = false.obs;
|
||||
var authList = List<AuthResponse>.empty(growable: true).obs;
|
||||
|
||||
void signinUser(String email, String password) async {
|
||||
try{
|
||||
isLoading(true);
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/login/';
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: convert.jsonEncode(<String, String>{
|
||||
'email': email,
|
||||
'password': password
|
||||
}),
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
print(response.body);
|
||||
AuthResponse authResponse = AuthResponse.fromJson(convert.jsonDecode(convert.utf8.decode(response.body.codeUnits)));
|
||||
print(authResponse.user.eventCode.toString());
|
||||
authList.assign(authResponse);
|
||||
}
|
||||
else{
|
||||
throw("Unable to Login, please check your creadentials");
|
||||
}
|
||||
}
|
||||
catch(e){
|
||||
Get.snackbar("Error", e.toString(), snackPosition: SnackPosition.BOTTOM);
|
||||
}
|
||||
finally{
|
||||
isLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
0
lib/screens/auth/views/login/login_binding.dart
Normal file
0
lib/screens/auth/views/login/login_binding.dart
Normal file
5
lib/screens/auth/views/login/login_controller.dart
Normal file
5
lib/screens/auth/views/login/login_controller.dart
Normal file
@ -0,0 +1,5 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class LoginController extends GetxController{
|
||||
|
||||
}
|
||||
75
lib/screens/auth/views/login/login_screen.dart
Normal file
75
lib/screens/auth/views/login/login_screen.dart
Normal file
@ -0,0 +1,75 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/common/ui/widgets/uis.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/screens/auth/common/uis/auth_text_field.dart';
|
||||
import 'package:rogapp/screens/auth/common/uis/rounded_small_button.dart';
|
||||
import 'package:rogapp/screens/auth/controller/auth_controller.dart';
|
||||
import 'package:rogapp/theme/theme.dart';
|
||||
|
||||
class LoginScreen extends StatelessWidget {
|
||||
final emailController = TextEditingController();
|
||||
final passwordController = TextEditingController();
|
||||
LoginScreen({super.key});
|
||||
|
||||
final AuthController authController = Get.find<AuthController>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: UIs.appBar(),
|
||||
body: Obx((){
|
||||
if(authController.isLoading.value) {
|
||||
return const Center(child: CircularProgressIndicator(),);
|
||||
} else {
|
||||
return Center(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
height: MediaQuery.of(context).size.height/6,
|
||||
decoration: const BoxDecoration(
|
||||
image:DecorationImage(image: AssetImage('assets/images/login_image.jpg'))
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5,),
|
||||
AuthTextField(controller: emailController, hinttext: 'Email',),
|
||||
const SizedBox(height: 25,),
|
||||
AuthTextField(controller: passwordController, hinttext: 'Password',),
|
||||
const SizedBox(height: 40,),
|
||||
Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: RoundedSmallButton(onTap: (){
|
||||
authController.signinUser(emailController.text, passwordController.text);
|
||||
},
|
||||
label: 'Done',),
|
||||
),
|
||||
const SizedBox(height: 40,),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: "Don't have an account?",
|
||||
style: const TextStyle(fontSize: 16, color: Pallete.BROWN_COLOR),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: " Signup",
|
||||
style: const TextStyle(color: Pallete.BLUE_COLOR, fontSize: 16),
|
||||
recognizer: TapGestureRecognizer()..onTap = (){
|
||||
Get.toNamed(AppPages.S_REGISTER);
|
||||
},
|
||||
),
|
||||
]
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
10
lib/screens/auth/views/register/register_screen.dart
Normal file
10
lib/screens/auth/views/register/register_screen.dart
Normal file
@ -0,0 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class RegisterScreen extends StatelessWidget {
|
||||
const RegisterScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
12
lib/screens/home/home_binding.dart
Normal file
12
lib/screens/home/home_binding.dart
Normal file
@ -0,0 +1,12 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/screens/home/home_controller.dart';
|
||||
import 'package:rogapp/screens/home/location_controller.dart';
|
||||
|
||||
class HomeBinding extends Bindings{
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.put(HomeController());
|
||||
Get.put(LocationController());
|
||||
}
|
||||
|
||||
}
|
||||
124
lib/screens/home/home_controller.dart
Normal file
124
lib/screens/home/home_controller.dart
Normal file
@ -0,0 +1,124 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogapp/model/location_response.dart';
|
||||
import 'package:rogapp/screens/auth/controller/auth_controller.dart';
|
||||
import 'package:rogapp/screens/home/location_controller.dart';
|
||||
import 'package:rogapp/utils/const.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert' as convert;
|
||||
|
||||
import 'package:rogapp/utils/db_helper.dart';
|
||||
|
||||
class HomeController extends GetxController{
|
||||
var isLoading = false.obs;
|
||||
List<LatLngBounds> currentBound = <LatLngBounds>[].obs;
|
||||
List<Feature> currentFeaturesforBound = <Feature>[].obs;
|
||||
List<Feature> currentFeature = <Feature>[].obs;
|
||||
MapController mapController = MapController();
|
||||
|
||||
late StreamSubscription<ConnectivityResult> _connectivitySubscription;
|
||||
ConnectivityResult connectionStatus = ConnectivityResult.none;
|
||||
var connectionStatusName = "".obs;
|
||||
final Connectivity _connectivity = Connectivity();
|
||||
|
||||
AuthController authController = Get.find<AuthController>();
|
||||
DatabaseHelper dbaseHelper = DatabaseHelper.instance;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
_connectivitySubscription = _connectivity.onConnectivityChanged.listen(_updateConnectionStatus);
|
||||
dbaseHelper.deleteAll().then((value){
|
||||
fetchBoundForuser(authController.authList[0].token);
|
||||
loadLocationsForBound().then((_){
|
||||
fetchLocalLocationForBound(mapController.bounds!);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _updateConnectionStatus(ConnectivityResult result) async {
|
||||
connectionStatus = result;
|
||||
connectionStatusName.value = result.name;
|
||||
}
|
||||
|
||||
void fetchLocalLocationForBound(LatLngBounds bound) async {
|
||||
final locations = await dbaseHelper.getFeaturesWithinBounds(bound);
|
||||
currentFeaturesforBound.assignAll(locations);
|
||||
print("loading locations ${currentFeaturesforBound.length} ------");
|
||||
}
|
||||
|
||||
Future<void> loadLocationsForBound() async {
|
||||
LatLngBounds bounds = mapController.bounds!;
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
try{
|
||||
isLoading(true);
|
||||
if(bounds.southWest != null && bounds.northEast != null){
|
||||
bool _rog = authController.authList[0].user.isRogaining;
|
||||
String r = _rog == true ? 'True': 'False';
|
||||
var grp = authController.authList[0].user.eventCode;
|
||||
final url = '$serverUrl/api/inbound?rog=${r}&grp=$grp&ln1=${bounds.southWest!.longitude}&la1=${bounds.southWest!.latitude}&ln2=${bounds.northWest.longitude}&la2=${bounds.northWest.latitude}&ln3=${bounds.northEast!.longitude}&la3=${bounds.northEast!.latitude}&ln4=${bounds.southEast.longitude}&la4=${bounds.southEast.latitude}';
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
// Parse JSON response
|
||||
LocationResponse locationResponse = LocationResponse.fromMap(convert.jsonDecode(convert.utf8.decode(response.body.codeUnits)));
|
||||
|
||||
// For each feature in the location response
|
||||
for (var feature in locationResponse.features!) {
|
||||
await dbaseHelper.insertFeature(feature.toMap());
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw("Unable to load locations, please try again ...");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(e, st){
|
||||
Get.snackbar("Error", e.toString(), snackPosition: SnackPosition.BOTTOM);
|
||||
}
|
||||
finally{
|
||||
isLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
void fetchBoundForuser(String usertoken) async {
|
||||
try{
|
||||
isLoading(true);
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/locsext/';
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': 'Token $usertoken'
|
||||
},
|
||||
body: convert.jsonEncode(<String, String>{
|
||||
'token': usertoken,
|
||||
}),
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
final ext = convert.json.decode(convert.utf8.decode(response.body.codeUnits));
|
||||
LatLngBounds bnds = LatLngBounds(LatLng(ext[1], ext[0]), LatLng(ext[3], ext[2]));
|
||||
currentBound.assign(bnds);
|
||||
mapController.fitBounds(bnds);
|
||||
}
|
||||
else{
|
||||
throw("Unable to query current bound, please try again ...");
|
||||
}
|
||||
}
|
||||
catch(e){
|
||||
Get.snackbar("Error", e.toString(), snackPosition: SnackPosition.BOTTOM);
|
||||
}
|
||||
finally{
|
||||
isLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
183
lib/screens/home/home_screen.dart
Normal file
183
lib/screens/home/home_screen.dart
Normal file
@ -0,0 +1,183 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogapp/common/ui/widgets/uis.dart';
|
||||
import 'package:rogapp/model/location_response.dart';
|
||||
import 'package:rogapp/screens/home/home_controller.dart';
|
||||
import 'package:rogapp/screens/home/location_controller.dart';
|
||||
import 'package:rogapp/theme/theme.dart';
|
||||
import 'package:rogapp/utils/db_helper.dart';
|
||||
import 'package:rogapp/utils/text_util.dart';
|
||||
import 'package:rogapp/widgets/base_layer_widget.dart';
|
||||
import 'package:rogapp/widgets/bottom_sheet_new.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
|
||||
class HomeScreen extends StatelessWidget {
|
||||
HomeScreen({super.key});
|
||||
StreamSubscription? subscription;
|
||||
final HomeController homeController = Get.find<HomeController>();
|
||||
final LocationController locationController = Get.find<LocationController>();
|
||||
|
||||
final double zoomThreshold = 0.08;
|
||||
final double boundsThreshold = 0.0005;
|
||||
|
||||
LatLngBounds? lastBounds;
|
||||
double? lastZoom;
|
||||
|
||||
|
||||
Widget getMarkerShape(Feature i, BuildContext context){
|
||||
|
||||
//print("lat is ${p.geoSerie!.geoPoints[0].latitude} and lon is ${p.geoSerie!.geoPoints[0].longitude}");
|
||||
RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
homeController.currentFeature.assign(i);
|
||||
if(homeController.currentFeature != null) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
isDismissible: true,
|
||||
builder:((context) => BottomSheetNew())
|
||||
//builder:((context) => BottomSheetWidget())
|
||||
).whenComplete((){
|
||||
locationController.skip_gps = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
child: Container(
|
||||
height: 32,
|
||||
width: 32,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.transparent,
|
||||
border: Border.all(
|
||||
color: i.properties!.buy_point! > 0 ? Colors.blue : Colors.red,
|
||||
width: 3,
|
||||
style: BorderStyle.solid
|
||||
)
|
||||
),
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Icon(Icons.circle,size: 6.0,),
|
||||
i.properties!.cp == -1 ?
|
||||
Transform.rotate(
|
||||
alignment: Alignment.centerLeft,
|
||||
origin: Offset.fromDirection(1, 26),
|
||||
angle: 270 * pi / 180,
|
||||
child: Icon(Icons.play_arrow_outlined, color: Colors.red, size: 70,)):
|
||||
Container(color: Colors.transparent,),
|
||||
],
|
||||
)
|
||||
),
|
||||
),
|
||||
Container(color: Colors.white, child: Text(TextUtils.getDisplayTextForFeature(i), style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color:Colors.red,))),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
actions: [
|
||||
TextButton(onPressed: () async {
|
||||
DatabaseHelper dbaseHelper = DatabaseHelper.instance;
|
||||
final res = await dbaseHelper.getFeatureByLatLon(35.807369, 137.240684);
|
||||
print(res[0].toString());
|
||||
},
|
||||
child: const Text("Click", style: TextStyle(color: Colors.white),))
|
||||
],
|
||||
),
|
||||
body: Obx(() =>
|
||||
FlutterMap(
|
||||
mapController: homeController.mapController,
|
||||
options: MapOptions(
|
||||
onMapReady: (){
|
||||
homeController.mapController!.mapEventStream.listen((MapEvent mapEvent) {
|
||||
if (mapEvent is MapEventMoveStart) {
|
||||
}
|
||||
if (mapEvent is MapEventMoveEnd) {
|
||||
LatLngBounds bounds = homeController.mapController!.bounds!;
|
||||
homeController.currentBound.assign(bounds);
|
||||
final _cz = homeController.mapController.zoom;
|
||||
}
|
||||
});
|
||||
} ,
|
||||
onPositionChanged: (position, hasGesture){
|
||||
if (hasGesture) {
|
||||
LatLngBounds currentBounds = position.bounds!;
|
||||
|
||||
if (lastBounds != null && lastZoom != null) {
|
||||
// Compute difference between last bounds and current bounds
|
||||
double boundsDifference = lastBounds!.north - currentBounds.north +
|
||||
lastBounds!.south - currentBounds.south +
|
||||
lastBounds!.east - currentBounds.east +
|
||||
lastBounds!.west - currentBounds.west;
|
||||
|
||||
// Compute difference between last zoom and current zoom
|
||||
double zoomDifference = lastZoom! - position.zoom!;
|
||||
|
||||
if (boundsDifference.abs() > boundsThreshold || zoomDifference.abs() > zoomThreshold) {
|
||||
LatLngBounds bounds = homeController.mapController!.bounds!;
|
||||
homeController.currentBound.assign(bounds);
|
||||
print('----threshold reached ---');
|
||||
homeController.fetchLocalLocationForBound(bounds);
|
||||
//loadData(position.bounds); // Load new data when either threshold is exceeded
|
||||
}
|
||||
} else {
|
||||
LatLngBounds bounds = homeController.mapController!.bounds!;
|
||||
homeController.currentBound.assign(bounds);
|
||||
homeController.fetchLocalLocationForBound(bounds);
|
||||
//loadData(position.bounds); // Load new data if this is the first time
|
||||
}
|
||||
|
||||
lastBounds = currentBounds; // Update the last bounds
|
||||
lastZoom = position.zoom; // Update the last zoom
|
||||
|
||||
}
|
||||
},
|
||||
bounds: homeController.currentBound.isNotEmpty ? homeController.currentBound[0]: LatLngBounds.fromPoints([LatLng(35.03999881162295, 136.40587119778962), LatLng(36.642756778706904, 137.95226720406063)]),
|
||||
zoom: 14,
|
||||
maxZoom:18.4,
|
||||
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
|
||||
),
|
||||
children: [
|
||||
const BaseLayer(),
|
||||
CurrentLocationLayer(),
|
||||
homeController.currentFeaturesforBound.isNotEmpty ?
|
||||
MarkerLayer(
|
||||
markers:homeController.currentFeaturesforBound.map((i) {
|
||||
RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
|
||||
return Marker(
|
||||
anchorPos: AnchorPos.exactly(Anchor(108.0, 18.0)),
|
||||
height: 32.0,
|
||||
width: 120.0,
|
||||
point: LatLng(i.latitude!, i.longitude!),
|
||||
builder: (ctx){
|
||||
return getMarkerShape(i, context);
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
)
|
||||
:
|
||||
Center(child: CircularProgressIndicator()),
|
||||
],
|
||||
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
318
lib/screens/home/location_controller.dart
Normal file
318
lib/screens/home/location_controller.dart
Normal file
@ -0,0 +1,318 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
|
||||
import 'package:rogapp/model/location_response.dart';
|
||||
import 'package:rogapp/pages/camera/camera_page.dart';
|
||||
import 'package:rogapp/screens/auth/controller/auth_controller.dart';
|
||||
import 'package:rogapp/screens/home/home_controller.dart';
|
||||
import 'package:rogapp/utils/checkin_db_helper.dart';
|
||||
import 'package:rogapp/widgets/bottom_sheet_new.dart';
|
||||
|
||||
class LocationController extends GetxController{
|
||||
|
||||
HomeController homeController = Get.find<HomeController>();
|
||||
AuthController authController = Get.find<AuthController>();
|
||||
CheckinDBHelper checkinDBHelper = CheckinDBHelper.instance;
|
||||
|
||||
|
||||
late LocationSettings locationSettings;
|
||||
List<String> locationPermission = <String>[" -- starting -- "].obs;
|
||||
double current_lat = 0.0;
|
||||
double current_lon = 0.0;
|
||||
var is_gps_selected = true.obs;
|
||||
var is_checkingIn = false.obs;
|
||||
var moveMapwithGPS = false.obs;
|
||||
bool skip_gps = false;
|
||||
var is_photo_shoot = false.obs;
|
||||
final photos = <File>[].obs;
|
||||
Timer? _timer;
|
||||
int _start = 0;
|
||||
int chekcs = 0;
|
||||
var rogaining_counted = false.obs;
|
||||
|
||||
var is_in_checkin = false.obs;
|
||||
var is_in_rog = false.obs;
|
||||
var is_at_start = false.obs;
|
||||
var is_at_goal = false.obs;
|
||||
DateTime last_goal_at = DateTime.now().subtract(Duration(days:1));
|
||||
bool skip_10s = false;
|
||||
|
||||
bool checking_in = false;
|
||||
BuildContext? context;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
initGPS();
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
void checkPermission() async {
|
||||
LocationPermission permission = await Geolocator.checkPermission();
|
||||
if (permission != LocationPermission.whileInUse ||
|
||||
permission != LocationPermission.always) {
|
||||
locationPermission.clear();
|
||||
locationPermission.add(permission.name);
|
||||
permission = await Geolocator.requestPermission();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void initGPS(){
|
||||
checkPermission();
|
||||
|
||||
//print("------ in iniit");
|
||||
|
||||
if (defaultTargetPlatform == TargetPlatform.android) {
|
||||
locationSettings = AndroidSettings(
|
||||
accuracy: LocationAccuracy.bestForNavigation,
|
||||
distanceFilter: 0,
|
||||
forceLocationManager: true,
|
||||
intervalDuration: const Duration(seconds: 1),
|
||||
foregroundNotificationConfig: const ForegroundNotificationConfig(
|
||||
notificationText:
|
||||
"Thi app will continue to receive your location even when you aren't using it",
|
||||
notificationTitle: "Running in Background",
|
||||
enableWakeLock: true,
|
||||
)
|
||||
);
|
||||
} else if (defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.macOS) {
|
||||
locationSettings = AppleSettings(
|
||||
accuracy: LocationAccuracy.bestForNavigation,
|
||||
activityType: ActivityType.fitness,
|
||||
distanceFilter: 0,
|
||||
pauseLocationUpdatesAutomatically: false,
|
||||
// Only set to true if our app will be started up in the background.
|
||||
showBackgroundLocationIndicator: true
|
||||
);
|
||||
} else {
|
||||
locationSettings = const LocationSettings(
|
||||
accuracy: LocationAccuracy.high,
|
||||
distanceFilter: 0,
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
StreamSubscription<Position> positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen(
|
||||
|
||||
(Position? position) {
|
||||
current_lat = position != null ? position.latitude : 0;
|
||||
current_lon = position != null ? position.longitude : 0;
|
||||
|
||||
print('current GPS point is - $current_lat, $current_lon');
|
||||
|
||||
if(is_gps_selected.value){
|
||||
double czoom = homeController.mapController.zoom;
|
||||
if(moveMapwithGPS.value){
|
||||
homeController.mapController.move(LatLng(position!.latitude, position!.longitude), czoom);
|
||||
}
|
||||
|
||||
|
||||
//gps.clear();
|
||||
//gps.add("-- lat : ${position.latitude}, lon : ${position.longitude} --");
|
||||
if(is_checkingIn.value ==false || skip_gps == false){
|
||||
print("--- calling checkFoCheckin ---");
|
||||
checkFoCheckin();
|
||||
}
|
||||
//checkForCheckin(position!.latitude, position.longitude);
|
||||
|
||||
}
|
||||
//print(position == null ? 'Unknown' : 'current position is ${position.latitude.toString()}, ${position.longitude.toString()}');
|
||||
});
|
||||
} catch (err){
|
||||
locationPermission.clear();
|
||||
locationPermission.add(err.toString());
|
||||
}
|
||||
|
||||
//ever(indexController.connectionStatusName, connectionChanged);
|
||||
}
|
||||
|
||||
void checkFoCheckin(){
|
||||
|
||||
for(final f in homeController.currentFeaturesforBound){
|
||||
|
||||
if(skip_gps) return;
|
||||
|
||||
var distance = Distance();
|
||||
var dist = distance.as(LengthUnit.Meter, LatLng(f.latitude!, f.longitude!), LatLng(current_lat, current_lon));
|
||||
|
||||
if(dist <= 250 && is_checkingIn.value == false){
|
||||
startTimer(f, dist);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void startTimer(Feature d, double distance) async {
|
||||
skip_gps = true;
|
||||
print("---- in startTimer ----");
|
||||
double checkin_radious = d.properties!.checkin_radius ?? double.infinity;
|
||||
bool auto_checkin = d.properties!.auto_checkin == 0 ? false : true;
|
||||
bool location_already_checked_in = await checkinDBHelper.exists(d.location_id!);
|
||||
bool isUser_logged_in = authController.authList.length > 0 ? true : false;
|
||||
//make current destination
|
||||
print("---- locationid : ${d.location_id} checkin radius ---- ${checkin_radious} --- distance : ${distance} ----");
|
||||
print("---- distance ${distance} ----");
|
||||
if(checkin_radious >= distance){
|
||||
//currentSelectedDestinations.add(d);
|
||||
homeController.currentFeature.assign(d);
|
||||
}
|
||||
else {
|
||||
skip_gps = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if(is_photo_shoot.value == true){
|
||||
photos.clear();
|
||||
showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
builder:((context) => CameraPage())
|
||||
).whenComplete((){
|
||||
skip_gps = false;
|
||||
chekcs = 0;
|
||||
is_in_checkin.value = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
List<Feature> ds = homeController.currentFeature;
|
||||
if(ds.isNotEmpty){
|
||||
if(d.properties!.cp == -1 && DateTime.now().difference(last_goal_at).inHours >= 24){
|
||||
chekcs = 1;
|
||||
//start
|
||||
print("---- in start -----");
|
||||
chekcs = 1;
|
||||
is_in_checkin.value = true;
|
||||
is_at_start.value = true;
|
||||
showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
builder:((context) => BottomSheetNew())
|
||||
).whenComplete((){
|
||||
skip_gps = false;
|
||||
chekcs = 0;
|
||||
is_at_start.value = false;
|
||||
is_in_checkin.value = false;
|
||||
});
|
||||
}
|
||||
else if(is_in_rog.value == true)
|
||||
{
|
||||
print("----- in location popup checkin cp - ${d.properties!.cp}----");
|
||||
chekcs = 2;
|
||||
is_in_checkin.value = true;
|
||||
showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
builder:((context) => BottomSheetNew())
|
||||
).whenComplete((){
|
||||
skip_gps = false;
|
||||
chekcs =0;
|
||||
is_in_checkin.value = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
print("---- location checkin radious ${d.properties!.checkin_radius} ----");
|
||||
print("---- already checked in ${location_already_checked_in} ----");
|
||||
if(checkin_radious >= distance && location_already_checked_in == false){
|
||||
if(auto_checkin){
|
||||
if(!checking_in){
|
||||
makeCheckin(d, true,"");
|
||||
if(d.properties!.cp != -1){
|
||||
rogaining_counted.value =true;
|
||||
}
|
||||
skip_gps = false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
print("--- hidden loc ${d.properties!.hidden_location} ----");
|
||||
// ask for checkin
|
||||
if(d.properties!.hidden_location != null && d.properties!.hidden_location == 0 && d.properties!.cp != -1){
|
||||
chekcs = 3;
|
||||
is_in_checkin.value = true;
|
||||
photos.clear();
|
||||
showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
builder:((context) => CameraPage(destination: d,))
|
||||
).whenComplete((){
|
||||
skip_gps = false;
|
||||
rogaining_counted.value =true;
|
||||
chekcs = 0;
|
||||
is_in_checkin.value = false;
|
||||
});
|
||||
}
|
||||
else if(is_in_rog.value == true && d.properties!.cp != -1){
|
||||
chekcs = 4;
|
||||
is_in_checkin.value = true;
|
||||
showMaterialModalBottomSheet(
|
||||
expand: true,
|
||||
context: Get.context!,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (context) => BottomSheetNew()
|
||||
).whenComplete(() {
|
||||
skip_gps = false;
|
||||
chekcs = 0;
|
||||
is_in_checkin.value = false;
|
||||
});
|
||||
// showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
// builder:((context) => BottomSheetNew())
|
||||
// ).whenComplete((){
|
||||
// skip_gps = false;
|
||||
// chekcs = 0;
|
||||
// is_in_checkin.value = false;
|
||||
// });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if(isUser_logged_in && d.properties!.cp == -1 && location_already_checked_in && skip_10s == false){
|
||||
//check for rogaining
|
||||
if(is_at_goal.value == false && rogaining_counted.value){
|
||||
//goal
|
||||
print("---- in goal -----");
|
||||
chekcs = 5;
|
||||
is_at_goal.value = true;
|
||||
photos.clear();
|
||||
showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
builder:((context) => CameraPage(destination: d,))
|
||||
).whenComplete((){
|
||||
skip_gps = false;
|
||||
chekcs = 0;
|
||||
is_at_goal.value = false;
|
||||
});
|
||||
}
|
||||
else if(is_in_rog.value == false && DateTime.now().difference(last_goal_at).inHours >= 24){
|
||||
//start
|
||||
print("---- in start -----");
|
||||
chekcs = 6;
|
||||
is_at_start.value = true;
|
||||
showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
builder:((context) => BottomSheetNew())
|
||||
).whenComplete((){
|
||||
print("----- finished start -------");
|
||||
skip_gps = false;
|
||||
chekcs = 0;
|
||||
is_at_start.value = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
print("==== _chekcs ${chekcs} ====");
|
||||
if(chekcs == 0){
|
||||
skip_gps = false;
|
||||
}
|
||||
}
|
||||
|
||||
void makeCheckin(Feature destination, bool action, String imageurl) async {
|
||||
|
||||
}
|
||||
|
||||
void addToRogaining(double lat, double lon, int destination_id) async {
|
||||
|
||||
}
|
||||
|
||||
void destinationMatrixFromCurrentPoint(List<Feature> ls){
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -11,8 +11,7 @@ class ActionService{
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = "${server_url}/api/makeaction/?user_id=${user_id}&location_id=${location_id}&wanttogo=${wanttogo}&like=${like}&checkin=${checkin}";
|
||||
//String url = "http://localhost:8100/api/makeaction/?user_id=${user_id}&location_id=${location_id}&wanttogo=${wanttogo}&like=${like}&checkin=${checkin}";
|
||||
print('++++++++${url}');
|
||||
print("url is ------ ${url}");
|
||||
print('@@@@@@+++ action_service MAKEACTION - GET, @@@@@@ ${url}');
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
@ -31,7 +30,7 @@ class ActionService{
|
||||
List<dynamic> cats = [];
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = '${server_url}/api/useraction/?user_id=${user_id}&location_id=${location_id}';
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ action_service USERACTION - GET, @@@@@@ ${url}');
|
||||
//String url = 'http://localhost:8100/api/useraction/?user_id=${user_id}&location_id=${location_id}';
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
|
||||
@ -10,7 +10,7 @@ class AuthService{
|
||||
Map<String, dynamic> changePassword = {};
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = '${server_url}/api/change-password/';
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ auth_service CHANGE PASSWORD - PUT with old_password : ${oldpassword} new_password : ${newpassword}, @@@@@@ ${url}');
|
||||
final http.Response response = await http.put(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
@ -31,11 +31,11 @@ class AuthService{
|
||||
|
||||
|
||||
static Future<Map<String, dynamic>> login(String email, String password) async {
|
||||
print("------- in logged email ${email} pwd ${password} ###### --------");
|
||||
//print("------- in logged email ${email} pwd ${password} ###### --------");
|
||||
Map<String, dynamic> cats = {};
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = '${server_url}/api/login/';
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ auth_service LOGIN - POST with email : ${email} password : ${password}, @@@@@@ ${url}');
|
||||
//String url = 'http://localhost:8100/api/login/';
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url),
|
||||
@ -59,7 +59,7 @@ class AuthService{
|
||||
Map<String, dynamic> cats = {};
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = '${server_url}/api/register/';
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ auth_service REGISTER - POST with email : ${email} password : ${password}, @@@@@@ ${url}');
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
@ -81,7 +81,7 @@ class AuthService{
|
||||
Map<String, dynamic> cats = {};
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = '${server_url}/api/delete-account/';
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ auth_service DELETE USER - GET with Authorization : Token ${token}, @@@@@@ ${url}');
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
@ -101,8 +101,7 @@ class AuthService{
|
||||
List<dynamic> cats = [];
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = '${server_url}/api/userdetials?user_id=${userid}';
|
||||
print('++++++++${url}');
|
||||
print("---- UserDetails url is ${url}");
|
||||
print('@@@@@@+++ auth_service USER DETAILS - GET, @@@@@@ ${url}');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
|
||||
@ -11,7 +11,7 @@ class CatService{
|
||||
List<dynamic> cats = [];
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = '${server_url}/api/cats/?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ cat_service LOADCATS - GET, @@@@@@ ${url}');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
@ -30,7 +30,7 @@ class CatService{
|
||||
List<dynamic> cats = [];
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = '${server_url}/api/catbycity/?${cityname}';
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ cat_service CHANGE PASSWORD - GET, @@@@@@ ${url}');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
|
||||
@ -15,7 +15,7 @@ class DestinationService{
|
||||
List<dynamic> cats = [];
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = "${server_url}/api/destinations/?user_id=${user_id}";
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ destination_service GETDESTINATIONS - GET, @@@@@@ ${url}');
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
@ -33,7 +33,7 @@ class DestinationService{
|
||||
Map<String, dynamic> cats = {};
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = "${server_url}/api/delete_destination/?dest_id=${dest_id}";
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ destination_service DELETEDESTINATION - GET, @@@@@@ ${url}');
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
@ -52,7 +52,7 @@ class DestinationService{
|
||||
int cats = 0;
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = "${server_url}/api/updateorder/?user_action_id=${action_id}&order=${order}&dir=${dir}";
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ destination_service UPDATEORDER - GET, @@@@@@ ${url}');
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
|
||||
@ -6,6 +6,8 @@ import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/model/rog.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/screens/auth/controller/auth_controller.dart';
|
||||
import 'package:rogapp/screens/home/home_controller.dart';
|
||||
import 'package:rogapp/utils/database_helper.dart';
|
||||
import 'package:sqflite/sqlite_api.dart';
|
||||
import 'dart:convert';
|
||||
@ -31,17 +33,19 @@ class ExternalService {
|
||||
|
||||
Future<Map<String, dynamic>> StartRogaining() async {
|
||||
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
//final IndexController indexController = Get.find<IndexController>();
|
||||
final homeController = Get.find<HomeController>();
|
||||
final authController = Get.find<AuthController>();
|
||||
|
||||
Map<String, dynamic> _res = {};
|
||||
|
||||
int user_id = indexController.currentUser[0]["user"]["id"];
|
||||
int user_id = authController.authList[0].user.id;
|
||||
//print("--- Pressed -----");
|
||||
String _team = indexController.currentUser[0]["user"]['team_name'];
|
||||
String _team = authController.authList[0].user.teamName;
|
||||
//print("--- _team : ${_team}-----");
|
||||
String _event_code = indexController.currentUser[0]["user"]["event_code"];
|
||||
String _event_code = authController.authList[0].user.eventCode;
|
||||
|
||||
if(indexController.connectionStatusName != "wifi" && indexController.connectionStatusName != "mobile"){
|
||||
if(homeController.connectionStatusName != "wifi" && homeController.connectionStatusName != "mobile"){
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
Rog _rog = Rog(
|
||||
id:1,
|
||||
@ -57,7 +61,7 @@ class ExternalService {
|
||||
}
|
||||
else {
|
||||
String url = 'https://natnats.mobilous.com/start_from_rogapp';
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ external_service STARTROGAINING - POST with team_name : ${_team} event_code : ${_event_code}, @@@@@@ ${url}');
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
@ -82,7 +86,6 @@ class ExternalService {
|
||||
Future<Map<String, dynamic>> makeCheckpoint(int user_id, String token, String checkin_time, String teamname, int cp, String eventcode, String imageurl) async {
|
||||
Map<String, dynamic> _res = {};
|
||||
String url = 'https://natnats.mobilous.com/checkin_from_rogapp';
|
||||
print('++++++++${url}');
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
|
||||
if(imageurl != null){
|
||||
@ -106,7 +109,7 @@ class ExternalService {
|
||||
String url1 = "${server_url}/api/checkinimage/";
|
||||
final im1Bytes = File(imageurl!).readAsBytesSync();
|
||||
String im1_64 = base64Encode(im1Bytes);
|
||||
|
||||
print('@@@@@@+++ external_service MAKECHECKPOINT - POST with user : ${user_id.toString()} team_name : ${teamname} event_code : ${eventcode} checkinimage : ${im1_64} checkintime : ${checkin_time} cp_number : ${cp.toString()}, @@@@@@ ${url1}');
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url1),
|
||||
headers: <String, String>{
|
||||
@ -130,6 +133,8 @@ class ExternalService {
|
||||
|
||||
if(response.statusCode == 201){
|
||||
//print('---- toekn is ${token} -----');
|
||||
String imgUrl = _res["checkinimage"].toString().replaceAll('http://localhost:8100', 'http://rogaining.sumasen.net');
|
||||
print('@@@@@@+++ external_service MAKECHECKPOINT - POST with team_name : ${teamname} event_code : ${eventcode} checkinimage : ${imgUrl} cp_number : ${cp.toString()}, @@@@@@ ${url}');
|
||||
final http.Response response2 = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
@ -166,6 +171,7 @@ class ExternalService {
|
||||
db.insertRogaining(_rog);
|
||||
}
|
||||
else {
|
||||
print('@@@@@@+++ external_service MAKECHECKPOINT - POST with team_name : ${teamname} event_code : ${eventcode} cp_number : ${cp.toString()} image : "", @@@@@@ ${url}');
|
||||
final http.Response response3 = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
@ -214,7 +220,7 @@ class ExternalService {
|
||||
String url1 = "${server_url}/api/goalimage/";
|
||||
final im1Bytes = File(image!).readAsBytesSync();
|
||||
String im1_64 = base64Encode(im1Bytes);
|
||||
|
||||
print('@@@@@@+++ external_service MAKEGOAL - POST with user : ${user_id.toString()} team_name : ${teamname} event_code : ${eventcode} goaltime : ${goal_time} cp_number : -1 goalimage : ${im1_64}, @@@@@@ ${url1}');
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url1),
|
||||
headers: <String, String>{
|
||||
@ -233,11 +239,10 @@ class ExternalService {
|
||||
);
|
||||
|
||||
String url = 'https://natnats.mobilous.com/goal_from_rogapp';
|
||||
print('++++++++${url}');
|
||||
if (response.statusCode == 201) {
|
||||
Map<String, dynamic> _res = json.decode(utf8.decode(response.bodyBytes));
|
||||
print('----_res : ${_res} ----');
|
||||
print('---- image url ${_res["goalimage"]} ----');
|
||||
String imgUrl = _res["goalimage"].toString().replaceAll('http://localhost:8100', 'http://rogaining.sumasen.net');
|
||||
print('@@@@@@+++ external_service MAKEGOAL - POST with team_name : ${teamname} event_code : ${eventcode} goal_time : ${goal_time} goalimage : ${imgUrl}, @@@@@@ ${url}');
|
||||
final http.Response response2 = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
@ -265,7 +270,7 @@ class ExternalService {
|
||||
static Future<Map<String, dynamic>> usersEventCode(String teamcode, String password) async {
|
||||
Map<String, dynamic> _res = {};
|
||||
String url = "https://natnats.mobilous.com/check_event_code?zekken_number=${teamcode}&password=${password}";
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ external_service USEREVENTCODE - GET, @@@@@@ ${url}');
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
|
||||
@ -61,7 +61,7 @@ class LocationService{
|
||||
url = '${server_url}/api/inperf/?perf=' + perfecture;
|
||||
}
|
||||
}
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ location_service LOADLOCATIONFOR - GET, @@@@@@ ${url}');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
@ -80,7 +80,7 @@ class LocationService{
|
||||
List<dynamic> ext = [];
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = '${server_url}/api/locsext/';
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ location_service GETLOCATIONEXT - POST, with token : ${token} @@@@@@ ${url}');
|
||||
final response = await http.post(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
@ -125,7 +125,7 @@ class LocationService{
|
||||
url = '${server_url}/api/insubperf?subperf=' + subperfecture;
|
||||
}
|
||||
}
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ location_service LOADLOCATIONSUBFOR - GET, @@@@@@ ${url}');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
@ -169,7 +169,7 @@ class LocationService{
|
||||
url = '${server_url}/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
|
||||
}
|
||||
}
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ location_service LOADLOCATIONSBOUNDS - GET, @@@@@@ ${url}');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
@ -224,7 +224,7 @@ class LocationService{
|
||||
url = '${server_url}/api/customarea?name=${name}';
|
||||
}
|
||||
}
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ location_service LOADCUSTOMLOCATIONS - GET, @@@@@@ ${url}');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
|
||||
@ -54,7 +54,7 @@ class MatrixService{
|
||||
|
||||
Map<String, dynamic> cats = {};
|
||||
String url = "https://maps.googleapis.com/maps/api/directions/json?destination=${destination}&mode=${_mode}&waypoints=${locs}&origin=${origin}&key=AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE";
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ matrix_service GETDESTINATIONS - GET, @@@@@@ ${url}');
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
|
||||
@ -9,7 +9,7 @@ class PerfectureService{
|
||||
List<dynamic> perfs = [];
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = '${server_url}/api/perf_main/';
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ perfeture_service LOADPERFECTURES - GET, @@@@@@ ${url}');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
@ -27,7 +27,7 @@ class PerfectureService{
|
||||
List<dynamic> perfs = [];
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = '${server_url}/api/subperfinmain/?area=' + area;
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ perfeture_service LOADSUBPERFECTURES - GET, @@@@@@ ${url}');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
@ -46,7 +46,7 @@ class PerfectureService{
|
||||
List<dynamic> perfs = [];
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = '${server_url}/api/mainperfext/?perf=' + id;
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ perfeture_service GETMAINPERFEXT - GET, @@@@@@ ${url}');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
@ -64,7 +64,7 @@ class PerfectureService{
|
||||
List<dynamic> perfs = [];
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = '${server_url}/api/allgifuareas/?perf=' + perf;
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ perfeture_service LOADGIFUAREAS - GET, @@@@@@ ${url}');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
@ -82,7 +82,7 @@ class PerfectureService{
|
||||
List<dynamic> perfs = [];
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = '${server_url}/api/customareanames';
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ perfeture_service LOADCUSTOMAREAS - GET, @@@@@@ ${url}');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
@ -101,7 +101,7 @@ class PerfectureService{
|
||||
List<dynamic> perfs = [];
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = '${server_url}/api/perfext/?sub_perf=' + id;
|
||||
print('++++++++${url}');
|
||||
print('@@@@@@+++ perfeture_service GETSUBEXT - GET, @@@@@@ ${url}');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
|
||||
@ -12,8 +12,8 @@ class TrackingService {
|
||||
Map<String, dynamic> cats = {};
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = '${server_url}/api/track/';
|
||||
print('++++++++${url}');
|
||||
final geom = '{"type": "MULTIPOINT", "coordinates": [[${lon}, ${lat}]]}';
|
||||
print('@@@@@@+++ tracking_service ADDTRAACK - POST, with user_id : ${user_id} geom : ${geom} @@@@@@ ${url}');
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
|
||||
17
lib/theme/app_theme.dart
Normal file
17
lib/theme/app_theme.dart
Normal file
@ -0,0 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rogapp/theme/pallete.dart';
|
||||
|
||||
class AppTheme {
|
||||
static ThemeData theme = ThemeData.light(useMaterial3: true).copyWith(
|
||||
scaffoldBackgroundColor: Pallete.WHITE_COLOR,
|
||||
primaryColor: Pallete.BLUE_COLOR,
|
||||
secondaryHeaderColor: Pallete.GREEN_COLOR,
|
||||
appBarTheme: const AppBarTheme(
|
||||
color: Pallete.BACKGROUND_COLOR,
|
||||
elevation: 0
|
||||
),
|
||||
floatingActionButtonTheme: const FloatingActionButtonThemeData(
|
||||
backgroundColor: Pallete.BLUE_COLOR
|
||||
),
|
||||
);
|
||||
}
|
||||
10
lib/theme/pallete.dart
Normal file
10
lib/theme/pallete.dart
Normal file
@ -0,0 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class Pallete {
|
||||
static const Color BACKGROUND_COLOR = Color.fromRGBO(191, 33, 46, 1);
|
||||
static const Color SEARCHBAR_COLOR = Color.fromRGBO(191, 33, 120, 1);
|
||||
static const Color BLUE_COLOR = Color.fromRGBO(36, 163, 191, 1);
|
||||
static const Color GREEN_COLOR = Color.fromRGBO(31, 140, 58, 1);
|
||||
static const Color BROWN_COLOR = Color.fromRGBO(191, 135, 31, 1);
|
||||
static const Color WHITE_COLOR = Colors.white;
|
||||
}
|
||||
3
lib/theme/theme.dart
Normal file
3
lib/theme/theme.dart
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
export 'pallete.dart';
|
||||
export 'app_theme.dart';
|
||||
82
lib/utils/checkin_db_helper.dart
Normal file
82
lib/utils/checkin_db_helper.dart
Normal file
@ -0,0 +1,82 @@
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
import 'package:path/path.dart';
|
||||
|
||||
class CheckinDBHelper {
|
||||
static final _databaseName = "EventDatabase.db";
|
||||
static final _databaseVersion = 1;
|
||||
|
||||
static final table = 'event_table';
|
||||
|
||||
static final columnLocationId = 'location_id';
|
||||
static final columnOrderId = 'order_id';
|
||||
static final columnCheckinTime = 'checkin_time';
|
||||
static final columnEventName = 'event_name';
|
||||
|
||||
// make this a singleton class
|
||||
CheckinDBHelper._privateConstructor();
|
||||
static final CheckinDBHelper instance = CheckinDBHelper._privateConstructor();
|
||||
|
||||
// only have a single app-wide reference to the database
|
||||
static Database? _database;
|
||||
Future<Database> get database async {
|
||||
if (_database != null) return _database!;
|
||||
_database = await _initDatabase();
|
||||
return _database!;
|
||||
}
|
||||
|
||||
// this opens the database (and creates it if it doesn't exist)
|
||||
_initDatabase() async {
|
||||
String path = join(await getDatabasesPath(), _databaseName);
|
||||
return await openDatabase(path,
|
||||
version: _databaseVersion,
|
||||
onCreate: _onCreate);
|
||||
}
|
||||
|
||||
// SQL code to create the database table
|
||||
Future _onCreate(Database db, int version) async {
|
||||
await db.execute('''
|
||||
CREATE TABLE $table (
|
||||
$columnLocationId INTEGER PRIMARY KEY,
|
||||
$columnOrderId INTEGER NOT NULL,
|
||||
$columnCheckinTime TEXT NOT NULL,
|
||||
$columnEventName TEXT NOT NULL
|
||||
)
|
||||
''');
|
||||
}
|
||||
|
||||
// Helper methods
|
||||
|
||||
Future<int> insert(Map<String, dynamic> row) async {
|
||||
Database db = await instance.database;
|
||||
return await db.insert(table, row);
|
||||
}
|
||||
|
||||
Future<bool> exists(int locationId) async {
|
||||
Database db = await instance.database;
|
||||
List<Map<String, dynamic>> rows = await db.query(
|
||||
table,
|
||||
where: '$columnLocationId = ?',
|
||||
whereArgs: [locationId],
|
||||
);
|
||||
return rows.isNotEmpty;
|
||||
}
|
||||
|
||||
Future<List<Map<String, dynamic>>> queryAllRows() async {
|
||||
Database db = await instance.database;
|
||||
return await db.query(table);
|
||||
}
|
||||
|
||||
Future<List<Map<String, dynamic>>> queryRowsByLocation(int locationId) async {
|
||||
Database db = await instance.database;
|
||||
return await db.query(table,
|
||||
where: '$columnLocationId = ?',
|
||||
whereArgs: [locationId],
|
||||
);
|
||||
}
|
||||
|
||||
Future<int> update(Map<String, dynamic> row) async {
|
||||
Database db = await instance.database;
|
||||
int id = row[columnLocationId];
|
||||
return await db.update(table, row, where: '$columnLocationId = ?', whereArgs: [id]);
|
||||
}
|
||||
}
|
||||
170
lib/utils/db_helper.dart
Normal file
170
lib/utils/db_helper.dart
Normal file
@ -0,0 +1,170 @@
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:rogapp/model/location_response.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'dart:io';
|
||||
import 'dart:convert'; // for jsonEncode
|
||||
|
||||
class DatabaseHelper {
|
||||
static const _databaseName = "FeatureDatabase.db";
|
||||
static const _databaseVersion = 1;
|
||||
|
||||
// Singleton class
|
||||
DatabaseHelper._();
|
||||
static final DatabaseHelper instance = DatabaseHelper._();
|
||||
|
||||
Database? _database;
|
||||
Future<Database> get database async {
|
||||
if (_database != null) return _database!;
|
||||
_database = await _initDatabase();
|
||||
return _database!;
|
||||
}
|
||||
|
||||
Future<Database> _initDatabase() async {
|
||||
Directory documentsDirectory = await getApplicationDocumentsDirectory();
|
||||
String path = join(documentsDirectory.path, _databaseName);
|
||||
return await openDatabase(
|
||||
path,
|
||||
version: _databaseVersion,
|
||||
onCreate: _onCreate,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _onCreate(Database db, int version) async {
|
||||
await db.execute('''
|
||||
CREATE TABLE features (
|
||||
id INTEGER PRIMARY KEY,
|
||||
geometry TEXT NOT NULL,
|
||||
properties TEXT NOT NULL,
|
||||
type TEXT NOT NULL,
|
||||
location_id,
|
||||
latitude REAL NOT NULL,
|
||||
longitude REAL NOT NULL
|
||||
)
|
||||
''');
|
||||
}
|
||||
|
||||
// Database insert operation
|
||||
Future<void> insertFeature(Map<String, dynamic> feature) async {
|
||||
// Get a reference to the database.
|
||||
final db = await database;
|
||||
|
||||
// Insert the feature into the correct table.
|
||||
await db.insert(
|
||||
'features',
|
||||
feature,
|
||||
conflictAlgorithm: ConflictAlgorithm.replace,
|
||||
);
|
||||
}
|
||||
|
||||
// Database get operation
|
||||
Future<List<Feature>> getFeatures() async {
|
||||
Database db = await database;
|
||||
final List<Map<String, dynamic>> maps = await db.query('features');
|
||||
|
||||
return List.generate(maps.length, (i) {
|
||||
return Feature(
|
||||
id: maps[i]['id'],
|
||||
geometry: Geometry.fromMap(jsonDecode(maps[i]['geometry'])),
|
||||
properties: Properties.fromMap(jsonDecode(maps[i]['properties'])),
|
||||
type: maps[i]['type'],
|
||||
location_id: Properties.fromMap(jsonDecode(maps[i]['properties'])).location_id,
|
||||
latitude: Geometry.fromMap(jsonDecode(maps[i]['geometry'])).coordinates![0][1],
|
||||
longitude: Geometry.fromMap(jsonDecode(maps[i]['geometry'])).coordinates![0][0]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Database delete operation
|
||||
Future<void> deleteFeature(int id) async {
|
||||
Database db = await database;
|
||||
await db.delete(
|
||||
'features',
|
||||
where: "id = ?",
|
||||
whereArgs: [id],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> deleteAll() async {
|
||||
// Get a reference to the database.
|
||||
final db = await database;
|
||||
|
||||
// Delete all rows.
|
||||
await db.rawDelete('DELETE FROM features');
|
||||
}
|
||||
|
||||
// Database search by location_id
|
||||
Future<List<Feature>> getFeatureByLocationId(int locationId) async {
|
||||
Database db = await database;
|
||||
final List<Map<String, dynamic>> maps = await db.query(
|
||||
'features',
|
||||
where: "location_id = ?",
|
||||
whereArgs: [locationId],
|
||||
);
|
||||
|
||||
return List.generate(maps.length, (i) {
|
||||
return Feature(
|
||||
id: maps[i]['id'],
|
||||
geometry: Geometry.fromMap(jsonDecode(maps[i]['geometry'])),
|
||||
properties: Properties.fromMap(jsonDecode(maps[i]['properties'])),
|
||||
type: maps[i]['type'],
|
||||
location_id: Properties.fromMap(jsonDecode(maps[i]['properties'])).location_id,
|
||||
latitude: Geometry.fromMap(jsonDecode(maps[i]['geometry'])).coordinates![0][1],
|
||||
longitude: Geometry.fromMap(jsonDecode(maps[i]['geometry'])).coordinates![0][0]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Database search by latitude and longitude
|
||||
Future<List<Feature>> getFeatureByLatLon(double latitude, double longitude) async {
|
||||
Database db = await database;
|
||||
final List<Map<String, dynamic>> maps = await db.query(
|
||||
'features',
|
||||
where: "latitude = ? AND longitude = ?",
|
||||
whereArgs: [latitude, longitude],
|
||||
);
|
||||
|
||||
return List.generate(maps.length, (i) {
|
||||
return Feature(
|
||||
id: maps[i]['id'],
|
||||
geometry: Geometry.fromMap(jsonDecode(maps[i]['geometry'])),
|
||||
properties: Properties.fromMap(jsonDecode(maps[i]['properties'])),
|
||||
type: maps[i]['type'],
|
||||
location_id: Properties.fromMap(jsonDecode(maps[i]['properties'])).location_id,
|
||||
latitude: Geometry.fromMap(jsonDecode(maps[i]['geometry'])).coordinates![0][1],
|
||||
longitude: Geometry.fromMap(jsonDecode(maps[i]['geometry'])).coordinates![0][0]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Future<List<Feature>> getFeaturesWithinBounds(LatLngBounds bounds) async {
|
||||
final db = await database;
|
||||
|
||||
final List<Map<String, dynamic>> maps = await db.query(
|
||||
'features',
|
||||
where: 'latitude BETWEEN ? AND ? AND longitude BETWEEN ? AND ?',
|
||||
whereArgs: [
|
||||
bounds.southWest!.latitude,
|
||||
bounds.northEast!.latitude,
|
||||
bounds.southWest!.longitude,
|
||||
bounds.northEast!.longitude,
|
||||
],
|
||||
);
|
||||
|
||||
return List.generate(maps.length, (i) {
|
||||
return Feature(
|
||||
id: maps[i]['id'],
|
||||
geometry: Geometry.fromMap(jsonDecode(maps[i]['geometry'])),
|
||||
properties: Properties.fromMap(jsonDecode(maps[i]['properties'])),
|
||||
type: maps[i]['type'],
|
||||
location_id: Properties.fromMap(jsonDecode(maps[i]['properties'])).location_id,
|
||||
latitude: Geometry.fromMap(jsonDecode(maps[i]['geometry'])).coordinates![0][1],
|
||||
longitude: Geometry.fromMap(jsonDecode(maps[i]['geometry'])).coordinates![0][0]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/model/location_response.dart';
|
||||
|
||||
class TextUtils{
|
||||
|
||||
@ -18,22 +19,25 @@ class TextUtils{
|
||||
}
|
||||
|
||||
|
||||
static String getDisplayText(Destination dp){
|
||||
static String getDisplayText(Feature dp){
|
||||
RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
|
||||
String txt = "";
|
||||
if(dp.cp! > 0){
|
||||
txt = "${dp.cp.toString().replaceAll(regex, '')}";
|
||||
if(dp.checkin_point != null && dp.checkin_point! > 0){
|
||||
txt = txt + "{${dp.checkin_point.toString().replaceAll(regex, '')}}";
|
||||
if(dp.properties!.cp! > 0){
|
||||
txt = "${dp.properties!.cp.toString().replaceAll(regex, '')}";
|
||||
if(dp.properties!.checkin_point != null && dp.properties!.checkin_point! > 0){
|
||||
txt = txt + "{${dp.properties!.checkin_point.toString().replaceAll(regex, '')}}";
|
||||
}
|
||||
if(dp.buy_point != null && dp.buy_point! > 0){
|
||||
print("^^^^^^^^^ ${dp.sub_loc_id}^^^^^^^^^^");
|
||||
txt = "#${dp.cp.toString().replaceAll(regex, '')}(${dp.checkin_point.toString().replaceAll(regex, '')}+${dp.buy_point.toString().replaceAll(regex, '')})";
|
||||
if(dp.properties!.buy_point != null && dp.properties!.buy_point! > 0){
|
||||
txt = "#${dp.properties!.cp.toString().replaceAll(regex, '')}(${dp.properties!.checkin_point.toString().replaceAll(regex, '')}+${dp.properties!.buy_point.toString().replaceAll(regex, '')})";
|
||||
}
|
||||
}
|
||||
return txt;
|
||||
}
|
||||
|
||||
static String getDisplayTextForFeature(Feature f){
|
||||
return "${f.properties!.sub_loc_id}";
|
||||
}
|
||||
|
||||
// static String getDisplayText(String num){
|
||||
// RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
|
||||
// return "${num.replaceAll(regex, '')}";
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_map/plugin_api.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
@ -9,11 +7,13 @@ import 'package:image_picker/image_picker.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/pages/camera/camera_page.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/model/location_response.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/screens/auth/controller/auth_controller.dart';
|
||||
import 'package:rogapp/screens/home/home_controller.dart';
|
||||
import 'package:rogapp/screens/home/location_controller.dart';
|
||||
import 'package:rogapp/services/external_service.dart';
|
||||
import 'package:rogapp/utils/checkin_db_helper.dart';
|
||||
import 'package:rogapp/utils/const.dart';
|
||||
import 'package:rogapp/utils/database_helper.dart';
|
||||
import 'package:rogapp/utils/text_util.dart';
|
||||
@ -23,23 +23,26 @@ import 'package:url_launcher/url_launcher.dart';
|
||||
class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
BottomSheetNew({ Key? key }) : super(key: key);
|
||||
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
final DestinationController destinationController = Get.find<DestinationController>();
|
||||
//final IndexController indexController = Get.find<IndexController>();
|
||||
//final DestinationController destinationController = Get.find<DestinationController>();
|
||||
HomeController homeController = Get.find<HomeController>();
|
||||
LocationController locationController = Get.find<LocationController>();
|
||||
AuthController authController = Get.find<AuthController>();
|
||||
CheckinDBHelper checkinDBHelper = CheckinDBHelper.instance;
|
||||
|
||||
Image getImage(){
|
||||
|
||||
String server_url = ConstValues.currentServer();
|
||||
if(indexController.rog_mode == 1){
|
||||
//print("----- rogaining mode 1");
|
||||
if(indexController.currentDestinationFeature.length <= 0 || indexController.currentDestinationFeature[0].photos! == ""){
|
||||
if(homeController.currentFeature.isEmpty || homeController.currentFeature[0].properties!.photos == ""){
|
||||
return Image(image: AssetImage('assets/images/empty_image.png'));
|
||||
}
|
||||
else{
|
||||
//print("@@@@@@@@@@@@@ rog mode -------------------- ${indexController.currentDestinationFeature[0].photos} @@@@@@@@@@@");
|
||||
String _photo = indexController.currentDestinationFeature[0].photos!;
|
||||
String _photo = homeController.currentFeature[0].properties!.photos!;
|
||||
if(_photo.contains('http')){
|
||||
return Image(image: NetworkImage(
|
||||
indexController.currentDestinationFeature[0].photos!,
|
||||
homeController.currentFeature[0].properties!.photos!,
|
||||
),
|
||||
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
|
||||
return Image.asset("assets/images/empty_image.png");
|
||||
@ -48,7 +51,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
}
|
||||
else {
|
||||
return Image(image: NetworkImage(
|
||||
'${server_url}/media/compressed/' + indexController.currentDestinationFeature[0].photos!,
|
||||
'${server_url}/media/compressed/' + homeController.currentFeature[0].properties!.photos!,
|
||||
),
|
||||
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
|
||||
return Image.asset("assets/images/empty_image.png");
|
||||
@ -56,64 +59,31 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
GeoJsonFeature<dynamic> gf = indexController.currentFeature[0];
|
||||
if(gf!.properties!["photos"] == null || gf.properties!["photos"] == ""){
|
||||
return Image(image: AssetImage('assets/images/empty_image.png'));
|
||||
}
|
||||
else{
|
||||
String _photo = gf!.properties!["photos"];
|
||||
if(_photo.contains('http')){
|
||||
return Image(image: NetworkImage(
|
||||
gf.properties!["photos"],
|
||||
),
|
||||
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
|
||||
return Image.asset("assets/images/empty_image.png");
|
||||
},
|
||||
);
|
||||
}
|
||||
else {
|
||||
return Image(image: NetworkImage(
|
||||
'${server_url}/media/compressed/' + gf.properties!["photos"],
|
||||
),
|
||||
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
|
||||
return Image.asset("assets/images/empty_image.png");
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void _launchURL(url) async {
|
||||
if (!await launch(url)) throw 'Could not launch $url';
|
||||
}
|
||||
|
||||
bool isInDestination(String locationid){
|
||||
int lid = int.parse(locationid);
|
||||
if(destinationController.destinations.where((element) => element.location_id == lid).length > 0){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// bool isInDestination(String locationid){
|
||||
// int lid = int.parse(locationid);
|
||||
// if(destinationController.destinations.where((element) => element.location_id == lid).length > 0){
|
||||
// return true;
|
||||
// }
|
||||
// else{
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
destinationController.skip_gps = true;
|
||||
print('---- rog_mode ----- ${indexController.rog_mode} -----');
|
||||
return indexController.rog_mode == 0 ? detailsSheet(context) : destinationSheet(context);
|
||||
locationController.skip_gps = true;
|
||||
return destinationSheet(context);
|
||||
}
|
||||
|
||||
// Show destination detais
|
||||
SingleChildScrollView destinationSheet(BuildContext context) {
|
||||
|
||||
print('---- currentDestinationFeature ----- ${indexController.currentDestinationFeature[0].name} -----');
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
@ -141,14 +111,14 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
child: Obx(() =>
|
||||
indexController.currentUser.length > 0 ?
|
||||
Text("${TextUtils.getDisplayText(indexController.currentDestinationFeature[0])} : ${TextUtils.getDisplayText(indexController.currentDestinationFeature[0])} : ${indexController.currentDestinationFeature[0].name!}", style: TextStyle(
|
||||
authController.authList.isNotEmpty ?
|
||||
Text("${TextUtils.getDisplayText(homeController.currentFeature[0])} : ${TextUtils.getDisplayText(homeController.currentFeature[0])} : ${homeController.currentFeature[0].properties!.location_name}", style: TextStyle(
|
||||
fontSize: 15.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
)
|
||||
:
|
||||
Text("${indexController.currentDestinationFeature[0].name!}", style: TextStyle(
|
||||
Text("${homeController.currentFeature[0].properties!.location_name}", style: TextStyle(
|
||||
fontSize: 15.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
@ -174,38 +144,48 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Obx(() =>
|
||||
indexController.currentDestinationFeature.isNotEmpty && destinationController.is_in_checkin.value == true && destinationController.is_at_start.value == false ?
|
||||
homeController.currentBound.isNotEmpty && locationController.is_in_checkin.value == true && locationController.is_at_start.value == false ?
|
||||
Row(
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: (){
|
||||
if(indexController.currentDestinationFeature[0].checkedin == null || indexController.currentDestinationFeature[0].checkedin == false){
|
||||
if(indexController.currentDestinationFeature[0].hidden_location == 0){
|
||||
destinationController.skip_gps = false;
|
||||
destinationController.is_photo_shoot.value = true;
|
||||
onPressed: () async {
|
||||
final _locId = homeController.currentFeature[0].location_id;
|
||||
final _exist = await checkinDBHelper.exists(_locId!);
|
||||
if(_exist){
|
||||
if(homeController.currentFeature[0].properties!.hidden_location == 0){
|
||||
locationController.skip_gps = false;
|
||||
locationController.is_photo_shoot.value = true;
|
||||
Get.back();
|
||||
|
||||
}
|
||||
else{
|
||||
destinationController.makeCheckin(indexController.currentDestinationFeature[0], true, "");
|
||||
if(indexController.currentDestinationFeature[0].cp != -1){
|
||||
destinationController.rogaining_counted.value =true;
|
||||
locationController.makeCheckin(homeController.currentFeature[0], true, "");
|
||||
if(homeController.currentFeature[0].properties!.cp != -1){
|
||||
locationController.rogaining_counted.value =true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
destinationController.makeCheckin(indexController.currentDestinationFeature[0], false, "");
|
||||
locationController.makeCheckin(homeController.currentFeature[0], false, "");
|
||||
}
|
||||
//Get.back();
|
||||
},
|
||||
child: Text(
|
||||
//Checkin
|
||||
indexController.currentDestinationFeature[0].checkedin == null || indexController.currentDestinationFeature[0].checkedin == false ?
|
||||
"チェックイン"
|
||||
:
|
||||
"チェックアウト"
|
||||
)
|
||||
child: FutureBuilder<bool>(
|
||||
future: checkinDBHelper.exists(homeController.currentFeature[0].location_id!),
|
||||
builder: (BuildContext context, AsyncSnapshot<bool> snapshot){
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return CircularProgressIndicator(); // return a circular progress indicator while waiting
|
||||
} else {
|
||||
if (snapshot.hasError)
|
||||
return Text('Error: ${snapshot.error}'); // return error text if something went wrong
|
||||
else
|
||||
return snapshot.data! ?
|
||||
const Text("チェックイン") : // Widget to show if locationId exists
|
||||
const Text("チェックアウト");
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
@ -213,19 +193,28 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
Container(),
|
||||
),
|
||||
Obx(() =>
|
||||
destinationController.is_at_start.value == true ?
|
||||
locationController.is_at_start.value == true ?
|
||||
ElevatedButton(
|
||||
onPressed: (){
|
||||
destinationController.is_in_rog.value = true;
|
||||
destinationController.addToRogaining(destinationController.current_lat, destinationController.current_lon, indexController.currentDestinationFeature[0].location_id!);
|
||||
locationController.is_in_rog.value = true;
|
||||
locationController.addToRogaining(locationController.current_lat, locationController.current_lon, homeController.currentFeature[0].location_id!);
|
||||
ExternalService().StartRogaining().then((value) => Get.back());
|
||||
},
|
||||
child: Text(
|
||||
// start
|
||||
indexController.currentDestinationFeature[0].checkedin != null || indexController.currentDestinationFeature[0].checkedin == true ?
|
||||
"ロゲイニングを開始"
|
||||
:
|
||||
"間違った目的地..."
|
||||
child:
|
||||
FutureBuilder<bool>(
|
||||
future: checkinDBHelper.exists(homeController.currentFeature[0].location_id!),
|
||||
builder: (context, snapshot){
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return CircularProgressIndicator(); // return a circular progress indicator while waiting
|
||||
} else {
|
||||
if (snapshot.hasError)
|
||||
return Text('Error: ${snapshot.error}'); // return error text if something went wrong
|
||||
else
|
||||
return snapshot.data! ?
|
||||
const Text("ロゲイニングを開始") : // Widget to show if locationId exists
|
||||
const Text("間違った目的地...");
|
||||
}
|
||||
},
|
||||
)
|
||||
)
|
||||
:
|
||||
@ -233,18 +222,27 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
|
||||
),
|
||||
Obx(() =>
|
||||
destinationController.is_at_goal.value == true && destinationController.rogaining_counted ==true ?
|
||||
locationController.is_at_goal.value == true && locationController.rogaining_counted ==true ?
|
||||
ElevatedButton(
|
||||
onPressed: (){
|
||||
Get.toNamed(AppPages.CAMERA_PAGE);
|
||||
Get.back();
|
||||
},
|
||||
child: Text(
|
||||
//goal
|
||||
indexController.currentDestinationFeature[0].checkedin != null || indexController.currentDestinationFeature[0].checkedin == true ?
|
||||
"ロゲイニングを終える"
|
||||
:
|
||||
"間違った目的地 ..."
|
||||
child:
|
||||
FutureBuilder<bool>(
|
||||
future: checkinDBHelper.exists(homeController.currentFeature[0].location_id!),
|
||||
builder: (context, snapshot){
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return CircularProgressIndicator(); // return a circular progress indicator while waiting
|
||||
} else {
|
||||
if (snapshot.hasError)
|
||||
return Text('Error: ${snapshot.error}'); // return error text if something went wrong
|
||||
else
|
||||
return snapshot.data! ?
|
||||
const Text("ロゲイニングを終える") : // Widget to show if locationId exists
|
||||
const Text("間違った目的地 ...");
|
||||
}
|
||||
},
|
||||
)
|
||||
)
|
||||
:
|
||||
@ -254,32 +252,32 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
],
|
||||
),
|
||||
Obx(() =>
|
||||
indexController.currentDestinationFeature[0].address != null && indexController.currentDestinationFeature[0].address!.isNotEmpty ?
|
||||
getDetails(context, "address".tr, indexController.currentDestinationFeature[0].address! ?? '')
|
||||
homeController.currentFeature[0].properties!.address != null ?
|
||||
getDetails(context, "address".tr, homeController.currentFeature[0].properties!.address! ?? '')
|
||||
:
|
||||
Container(width: 0.0, height: 0,),
|
||||
),
|
||||
Obx(() =>
|
||||
indexController.currentDestinationFeature[0].phone != null && indexController.currentDestinationFeature[0].phone!.isNotEmpty ?
|
||||
getDetails(context, "telephone".tr, indexController.currentDestinationFeature[0].phone! ?? '')
|
||||
homeController.currentFeature[0].properties!.phone != null ?
|
||||
getDetails(context, "telephone".tr, homeController.currentFeature[0].properties!.phone! ?? '')
|
||||
:
|
||||
Container(width: 0.0, height: 0,),
|
||||
),
|
||||
Obx(() =>
|
||||
indexController.currentDestinationFeature[0].email != null && indexController.currentDestinationFeature[0].email!.isNotEmpty ?
|
||||
getDetails(context, "email".tr, indexController.currentDestinationFeature[0].email! ?? '')
|
||||
homeController.currentFeature[0].properties!.email != null ?
|
||||
getDetails(context, "email".tr, homeController.currentFeature[0].properties!.email! ?? '')
|
||||
:
|
||||
Container(width: 0.0, height: 0,),
|
||||
),
|
||||
Obx(() =>
|
||||
indexController.currentDestinationFeature[0].webcontents != null && indexController.currentDestinationFeature[0].webcontents!.isNotEmpty ?
|
||||
getDetails(context, "web".tr, indexController.currentDestinationFeature[0].webcontents! ?? '', isurl: true)
|
||||
homeController.currentFeature[0].properties!.webcontents != null ?
|
||||
getDetails(context, "web".tr, homeController.currentFeature[0].properties!.webcontents! ?? '', isurl: true)
|
||||
:
|
||||
Container(width: 0.0, height: 0,),
|
||||
),
|
||||
Obx(() =>
|
||||
indexController.currentDestinationFeature[0].videos != null && indexController.currentDestinationFeature[0].videos!.isNotEmpty ?
|
||||
getDetails(context, "video".tr, indexController.currentDestinationFeature[0].videos! ?? '', isurl: true)
|
||||
homeController.currentFeature[0].properties!.videos != null ?
|
||||
getDetails(context, "video".tr, homeController.currentFeature[0].properties!.videos! ?? '', isurl: true)
|
||||
:
|
||||
Container(width: 0.0, height: 0,),
|
||||
),
|
||||
@ -333,7 +331,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
child: Obx(() =>
|
||||
Text(indexController.currentFeature[0].properties!["location_name"], style: TextStyle(
|
||||
Text(homeController.currentFeature[0].properties!.location_name!, style: TextStyle(
|
||||
fontSize: 15.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
@ -364,38 +362,60 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Obx(() =>
|
||||
indexController.currentDestinationFeature.isNotEmpty && indexController.currentDestinationFeature[0].cp == -1 && indexController.currentDestinationFeature[0].checkedin == false && destinationController.is_at_start.value == true ?
|
||||
ElevatedButton(
|
||||
onPressed: (){
|
||||
destinationController.is_in_rog.value = true;
|
||||
destinationController.addToRogaining(destinationController.current_lat, destinationController.current_lon, indexController.currentDestinationFeature[0].location_id!);
|
||||
ExternalService().StartRogaining().then((value) => Get.back());
|
||||
},
|
||||
child: Text(
|
||||
// start
|
||||
indexController.currentDestinationFeature[0].checkedin != null || indexController.currentDestinationFeature[0].checkedin == true ?
|
||||
"ロゲイニングを開始"
|
||||
:
|
||||
"間違った目的地..."
|
||||
)
|
||||
)
|
||||
:
|
||||
Container(),
|
||||
|
||||
FutureBuilder<bool>(
|
||||
future: checkinDBHelper.exists(homeController.currentFeature[0].location_id!),
|
||||
builder: (context, snapshot){
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return CircularProgressIndicator(); // return a circular progress indicator while waiting
|
||||
} else {
|
||||
if (snapshot.hasError)
|
||||
return Text('Error: ${snapshot.error}'); // return error text if something went wrong
|
||||
else
|
||||
if(homeController.currentFeature[0].properties!.cp == -1 && locationController.is_at_start.value ==true){
|
||||
return ElevatedButton(
|
||||
onPressed: (){
|
||||
locationController.is_in_rog.value = true;
|
||||
locationController.addToRogaining(locationController.current_lat, locationController.current_lon, homeController.currentFeature[0].location_id!);
|
||||
ExternalService().StartRogaining().then((value) => Get.back());
|
||||
},
|
||||
child: Text(
|
||||
// start
|
||||
snapshot.data! == true ?
|
||||
"ロゲイニングを開始"
|
||||
:
|
||||
"間違った目的地..."
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
),
|
||||
Obx(() =>
|
||||
destinationController.is_at_goal.value == true && destinationController.rogaining_counted ==true ?
|
||||
locationController.is_at_goal.value == true && locationController.rogaining_counted ==true ?
|
||||
ElevatedButton(
|
||||
onPressed: (){
|
||||
Get.toNamed(AppPages.CAMERA_PAGE);
|
||||
Get.back();
|
||||
},
|
||||
child: Text(
|
||||
//goal
|
||||
indexController.currentDestinationFeature[0].checkedin != null || indexController.currentDestinationFeature[0].checkedin == true ?
|
||||
"ロゲイニングを終える"
|
||||
:
|
||||
"間違った目的地 ..."
|
||||
child:
|
||||
FutureBuilder<bool>(
|
||||
future: checkinDBHelper.exists(homeController.currentFeature[0].location_id!),
|
||||
builder: (context, snapshot){
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return CircularProgressIndicator(); // return a circular progress indicator while waiting
|
||||
} else {
|
||||
if (snapshot.hasError)
|
||||
return Text('Error: ${snapshot.error}'); // return error text if something went wrong
|
||||
else
|
||||
return snapshot.data! ?
|
||||
const Text("ロゲイニングを終える") : // Widget to show if locationId exists
|
||||
const Text("間違った目的地 ...");
|
||||
}
|
||||
},
|
||||
)
|
||||
)
|
||||
:
|
||||
@ -409,41 +429,56 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
indexController.currentDestinationFeature.isNotEmpty && destinationController.is_in_checkin.value == true ?
|
||||
Container()
|
||||
:
|
||||
FutureBuilder<Widget>(
|
||||
future: wantToGo(context),
|
||||
builder: (context, snapshot) {
|
||||
return Container(
|
||||
child: snapshot.data,
|
||||
);
|
||||
},
|
||||
),
|
||||
indexController.currentFeature[0].properties!["location_name"] != null && (indexController.currentFeature[0].properties!["location_name"] as String).isNotEmpty ?
|
||||
Flexible(child: Text(indexController.currentFeature[0].properties!["location_name"]))
|
||||
:
|
||||
Container(width: 0.0, height: 0,),
|
||||
FutureBuilder<bool>(
|
||||
future: checkinDBHelper.exists(homeController.currentFeature[0].location_id!),
|
||||
builder: (context, snapshot){
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return CircularProgressIndicator(); // return a circular progress indicator while waiting
|
||||
} else {
|
||||
if (snapshot.hasError)
|
||||
return Text('Error: ${snapshot.error}'); // return error text if something went wrong
|
||||
else{
|
||||
if(snapshot.data == true){
|
||||
return Container();
|
||||
}
|
||||
else{
|
||||
return FutureBuilder<Widget>(
|
||||
future: wantToGo(context),
|
||||
builder: (context, snapshot) {
|
||||
return Container(
|
||||
child: snapshot.data,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
// indexController.currentFeature[0].properties!["location_name"] != null && (indexController.currentFeature[0].properties!["location_name"] as String).isNotEmpty ?
|
||||
// Flexible(child: Text(indexController.currentFeature[0].properties!["location_name"]))
|
||||
// :
|
||||
// Container(width: 0.0, height: 0,),
|
||||
],
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed:() async {
|
||||
GeoJsonFeature<GeoJsonMultiPoint> mp = indexController.currentFeature[0] as GeoJsonFeature<GeoJsonMultiPoint>;
|
||||
Feature mp = homeController.currentFeature[0];
|
||||
Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
|
||||
Destination ds = Destination(
|
||||
lat: position.latitude,
|
||||
lon: position.longitude
|
||||
Feature ds = Feature(
|
||||
latitude: position.latitude,
|
||||
longitude: position.longitude
|
||||
);
|
||||
|
||||
Destination tp = Destination(
|
||||
lat: mp.geometry!.geoSerie!.geoPoints[0].latitude,
|
||||
lon: mp.geometry!.geoSerie!.geoPoints[0].longitude
|
||||
Feature tp = Feature(
|
||||
latitude: mp.latitude,
|
||||
longitude: mp.longitude
|
||||
);
|
||||
|
||||
Get.back();
|
||||
|
||||
destinationController.destinationMatrixFromCurrentPoint([ds, tp]);
|
||||
locationController.destinationMatrixFromCurrentPoint([ds, tp]);
|
||||
},
|
||||
child:Text("ここへ行く")),
|
||||
],
|
||||
@ -455,8 +490,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
children: [
|
||||
Icon(Icons.roundabout_left),
|
||||
SizedBox(width: 8.0,),
|
||||
indexController.currentFeature[0].properties!["address"] != null && (indexController.currentFeature[0].properties!["address"] as String).isNotEmpty ?
|
||||
getDetails(context, "address".tr, indexController.currentFeature[0].properties!["address"] ?? '')
|
||||
homeController.currentFeature[0].properties!.address != null && homeController.currentFeature[0].properties!.address!.isNotEmpty ?
|
||||
getDetails(context, "address".tr, homeController.currentFeature[0].properties!.address ?? '')
|
||||
:
|
||||
Container(width: 0.0, height: 0,),
|
||||
],
|
||||
@ -468,8 +503,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
children: [
|
||||
Icon(Icons.phone),
|
||||
SizedBox(width: 8.0,),
|
||||
indexController.currentFeature[0].properties!["phone"] != null && (indexController.currentFeature[0].properties!["phone"] as String).isNotEmpty ?
|
||||
getDetails(context, "telephone".tr, indexController.currentFeature[0].properties!["phone"] ?? '')
|
||||
homeController.currentFeature[0].properties!.phone != null && homeController.currentFeature[0].properties!.phone!.isNotEmpty ?
|
||||
getDetails(context, "telephone".tr, homeController.currentFeature[0].properties!.phone ?? '')
|
||||
:
|
||||
Container(width: 0.0, height: 0,),
|
||||
],
|
||||
@ -481,8 +516,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
children: [
|
||||
Icon(Icons.email),
|
||||
SizedBox(width: 8.0,),
|
||||
indexController.currentFeature[0].properties!["email"] != null && (indexController.currentFeature[0].properties!["email"] as String).isNotEmpty ?
|
||||
getDetails(context, "email".tr, indexController.currentFeature[0].properties!["email"] ?? '')
|
||||
homeController.currentFeature[0].properties!.email != null && homeController.currentFeature[0].properties!.email!.isNotEmpty ?
|
||||
getDetails(context, "email".tr, homeController.currentFeature[0].properties!.email ?? '')
|
||||
:
|
||||
Container(width: 0.0, height: 0,),
|
||||
],
|
||||
@ -494,8 +529,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
children: [
|
||||
Icon(Icons.language),
|
||||
SizedBox(width: 8.0,),
|
||||
indexController.currentFeature[0].properties!["webcontents"] != null && (indexController.currentFeature[0].properties!["webcontents"] as String).isNotEmpty ?
|
||||
getDetails(context, "web".tr, indexController.currentFeature[0].properties!["webcontents"] ?? '', isurl: true)
|
||||
homeController.currentFeature[0].properties!.webcontents != null && homeController.currentFeature[0].properties!.webcontents!.isNotEmpty ?
|
||||
getDetails(context, "web".tr, homeController.currentFeature[0].properties!.webcontents ?? '', isurl: true)
|
||||
:
|
||||
Container(width: 0.0, height: 0,),
|
||||
],
|
||||
@ -506,8 +541,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 8.0,),
|
||||
indexController.currentFeature[0].properties!["remark"] != null && (indexController.currentFeature[0].properties!["remark"] as String).isNotEmpty ?
|
||||
getDetails(context, "remarks".tr, indexController.currentFeature[0].properties!["remark"] ?? '', isurl: false)
|
||||
homeController.currentFeature[0].properties!.remark != null && homeController.currentFeature[0].properties!.remark!.isNotEmpty ?
|
||||
getDetails(context, "remarks".tr, homeController.currentFeature[0].properties!.remark ?? '', isurl: false)
|
||||
:
|
||||
Container(width: 0.0, height: 0,),
|
||||
],
|
||||
@ -529,15 +564,9 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
|
||||
Future<Widget> wantToGo(BuildContext context)async {
|
||||
|
||||
bool _selected = false;
|
||||
print('---target-- ${indexController.currentFeature[0].properties!["location_id"]}----');
|
||||
for(Destination d in destinationController.destinations){
|
||||
print('---- ${d.location_id.toString()} ----');
|
||||
if(d.location_id == indexController.currentFeature[0].properties!["location_id"]){
|
||||
_selected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool _selected = await checkinDBHelper.exists(homeController.currentFeature[0].location_id!);
|
||||
|
||||
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
return
|
||||
@ -547,196 +576,108 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
indexController.rog_mode == 0 ?
|
||||
IconButton(
|
||||
icon: Icon(Icons.pin_drop_sharp, size: 32, color: _selected == true ? Colors.amber : Colors.blue,),
|
||||
onPressed: (){
|
||||
if(_selected){
|
||||
// show remove from destination
|
||||
Get.defaultDialog(
|
||||
title: "本当にこのポイントを通過順から外しますか?",
|
||||
middleText: "場所は目的地リストから削除されます",
|
||||
backgroundColor: Colors.blue.shade300,
|
||||
titleStyle: TextStyle(color: Colors.white),
|
||||
middleTextStyle: TextStyle(color: Colors.white),
|
||||
textConfirm: "はい",
|
||||
textCancel: "いいえ",
|
||||
cancelTextColor: Colors.white,
|
||||
confirmTextColor: Colors.blue,
|
||||
buttonColor: Colors.white,
|
||||
barrierDismissible: false,
|
||||
radius: 10,
|
||||
content: Column(
|
||||
children: [
|
||||
],
|
||||
),
|
||||
onConfirm: (){
|
||||
int _id = indexController.currentFeature[0].properties!["location_id"];
|
||||
Destination? d = destinationController.destinationById(_id);
|
||||
print('--- des id is : ${d} -----');
|
||||
if(d != null) {
|
||||
//print('--- des id is : ${d.location_id} -----');
|
||||
destinationController.deleteDestination(d);
|
||||
Get.back();
|
||||
Get.back();
|
||||
Get.snackbar("追加した", "場所が削除されました");
|
||||
}
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
// show add to destination
|
||||
Get.defaultDialog(
|
||||
title: "この場所を登録してもよろしいですか",
|
||||
middleText: "ロケーションがロガニング リストに追加されます",
|
||||
backgroundColor: Colors.blue.shade300,
|
||||
titleStyle: TextStyle(color: Colors.white),
|
||||
middleTextStyle: TextStyle(color: Colors.white),
|
||||
textConfirm: "はい",
|
||||
textCancel: "いいえ",
|
||||
cancelTextColor: Colors.white,
|
||||
confirmTextColor: Colors.blue,
|
||||
buttonColor: Colors.white,
|
||||
barrierDismissible: false,
|
||||
radius: 10,
|
||||
content: Column(
|
||||
children: [
|
||||
],
|
||||
),
|
||||
onConfirm: (){
|
||||
GeoJsonMultiPoint mp = indexController.currentFeature[0].geometry as GeoJsonMultiPoint;
|
||||
LatLng pt = LatLng(mp.geoSerie!.geoPoints[0].latitude, mp.geoSerie!.geoPoints[0].longitude);
|
||||
|
||||
print("----- want to go sub location is ---- ${indexController.currentFeature[0].properties!["sub_loc_id"]} -----");
|
||||
|
||||
Destination dest = Destination(
|
||||
name: indexController.currentFeature[0].properties!["location_name"],
|
||||
address: indexController.currentFeature[0].properties!["address"],
|
||||
phone: indexController.currentFeature[0].properties!["phone"],
|
||||
email: indexController.currentFeature[0].properties!["email"],
|
||||
webcontents: indexController.currentFeature[0].properties!["webcontents"],
|
||||
videos: indexController.currentFeature[0].properties!["videos"],
|
||||
category: indexController.currentFeature[0].properties!["category"],
|
||||
series: 1,
|
||||
lat: pt.latitude,
|
||||
lon: pt.longitude,
|
||||
sub_loc_id: indexController.currentFeature[0].properties!["sub_loc_id"],
|
||||
location_id: indexController.currentFeature[0].properties!["location_id"],
|
||||
list_order: 1,
|
||||
photos: indexController.currentFeature[0].properties!["photos"],
|
||||
checkin_radious: indexController.currentFeature[0].properties!["checkin_radius"],
|
||||
auto_checkin: indexController.currentFeature[0].properties!["auto_checkin"] == true ? 1 : 0,
|
||||
cp: indexController.currentFeature[0].properties!["cp"],
|
||||
checkin_point: indexController.currentFeature[0].properties!["checkin_point"],
|
||||
buy_point: indexController.currentFeature[0].properties!["buy_point"],
|
||||
selected: false,
|
||||
checkedin: false,
|
||||
hidden_location: indexController.currentFeature[0].properties!["hidden_location"] == true ?1 : 0
|
||||
);
|
||||
destinationController.addDestinations(dest);
|
||||
Get.back();
|
||||
Get.back();
|
||||
Get.snackbar("追加した", "場所が追加されました");
|
||||
}
|
||||
);
|
||||
|
||||
},
|
||||
):
|
||||
Container(),
|
||||
SizedBox(width: 8.0,) ,
|
||||
Obx((() =>
|
||||
|
||||
indexController.rog_mode == 1 ?
|
||||
ElevatedButton(
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
Destination dest = indexController.currentDestinationFeature[0]!;
|
||||
Feature dest = homeController.currentFeature[0];
|
||||
//print("------ curent destination is ${dest!.checkedIn}-------");
|
||||
if(dest != null){
|
||||
//print("------ curent destination is ${dest!.checkedin}-------::::::::::");
|
||||
destinationController.makeCheckin(dest, !dest.checkedin!, "");
|
||||
bool checkin = await checkinDBHelper.exists(homeController.currentFeature[0].location_id!);
|
||||
locationController.makeCheckin(dest, checkin, "");
|
||||
}
|
||||
},
|
||||
child: indexController.currentDestinationFeature[0].checkedin == false ?
|
||||
Text("チェックイン")
|
||||
:
|
||||
Text("チェックアウト")
|
||||
):
|
||||
Container()
|
||||
child:
|
||||
FutureBuilder<bool>(
|
||||
future: checkinDBHelper.exists(homeController.currentFeature[0].location_id!),
|
||||
builder: (context, snapshot){
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return CircularProgressIndicator();
|
||||
|
||||
)
|
||||
),
|
||||
}else {
|
||||
if (snapshot.hasError)
|
||||
return Text('Error: ${snapshot.error}'); // return error text if something went wrong
|
||||
else
|
||||
return snapshot.data! ?
|
||||
const Text("チェックイン") : // Widget to show if locationId exists
|
||||
const Text("チェックアウト");
|
||||
}
|
||||
},
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget getCheckin(BuildContext context){
|
||||
// Widget getCheckin(BuildContext context){
|
||||
|
||||
//print("------ currentAction ----- ${indexController.currentAction}-----");
|
||||
// //print("------ currentAction ----- ${indexController.currentAction}-----");
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
indexController.currentAction[0][0]["checkin"] == false ?
|
||||
Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
child: Text("Image"), onPressed: (){
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
_picker.pickImage(source: ImageSource.camera).then((value){
|
||||
//print("----- image---- ${value!.path}");
|
||||
});
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: (){
|
||||
if(indexController.currentAction.isNotEmpty){
|
||||
//print(indexController.currentAction[0]);
|
||||
indexController.currentAction[0][0]["checkin"] = true;
|
||||
Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]);
|
||||
indexController.currentAction.clear();
|
||||
//print("---temp---${temp}");
|
||||
indexController.currentAction.add([temp]);
|
||||
}
|
||||
indexController.makeAction(context);
|
||||
},
|
||||
child: Text("checkin".tr)
|
||||
)
|
||||
],
|
||||
)
|
||||
:
|
||||
ElevatedButton(
|
||||
onPressed: (){
|
||||
if(indexController.currentAction.isNotEmpty){
|
||||
//print(indexController.currentAction[0]);
|
||||
indexController.currentAction[0][0]["checkin"] = false;
|
||||
Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]);
|
||||
indexController.currentAction.clear();
|
||||
//print("---temp---${temp}");
|
||||
indexController.currentAction.add([temp]);
|
||||
}
|
||||
indexController.makeAction(context);
|
||||
},
|
||||
// return Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: [
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: [
|
||||
// indexController.currentAction[0][0]["checkin"] == false ?
|
||||
// Column(
|
||||
// children: [
|
||||
// Row(
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
// children: [
|
||||
// ElevatedButton(
|
||||
// child: Text("Image"), onPressed: (){
|
||||
// final ImagePicker _picker = ImagePicker();
|
||||
// _picker.pickImage(source: ImageSource.camera).then((value){
|
||||
// //print("----- image---- ${value!.path}");
|
||||
// });
|
||||
// },
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ElevatedButton(
|
||||
// onPressed: (){},
|
||||
// //onPressed: (){
|
||||
// // if(indexController.currentAction.isNotEmpty){
|
||||
// // //print(indexController.currentAction[0]);
|
||||
// // indexController.currentAction[0][0]["checkin"] = true;
|
||||
// // Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]);
|
||||
// // indexController.currentAction.clear();
|
||||
// // //print("---temp---${temp}");
|
||||
// // indexController.currentAction.add([temp]);
|
||||
// // }
|
||||
// // indexController.makeAction(context);
|
||||
// // },
|
||||
// child: Text("checkin".tr)
|
||||
// )
|
||||
// ],
|
||||
// )
|
||||
// :
|
||||
// ElevatedButton(
|
||||
// onPressed: (){},
|
||||
// // onPressed: (){
|
||||
// // if(indexController.currentAction.isNotEmpty){
|
||||
// // //print(indexController.currentAction[0]);
|
||||
// // indexController.currentAction[0][0]["checkin"] = false;
|
||||
// // Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]);
|
||||
// // indexController.currentAction.clear();
|
||||
// // //print("---temp---${temp}");
|
||||
// // indexController.currentAction.add([temp]);
|
||||
// // }
|
||||
// // indexController.makeAction(context);
|
||||
// // },
|
||||
|
||||
child: Icon(
|
||||
Icons.favorite, color: Colors.red)
|
||||
// child: Icon(
|
||||
// Icons.favorite, color: Colors.red)
|
||||
|
||||
,
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
// ,
|
||||
// )
|
||||
// ],
|
||||
// )
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@ -749,13 +690,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
InkWell(
|
||||
onTap: (){
|
||||
if(isurl){
|
||||
if(indexController.rog_mode == 0){
|
||||
_launchURL(indexController.currentFeature[0].properties!["webcontents"]);
|
||||
}
|
||||
else {
|
||||
indexController.currentDestinationFeature[0].webcontents;
|
||||
}
|
||||
|
||||
_launchURL(homeController.currentFeature[0].properties!.webcontents);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
|
||||
@ -652,10 +652,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: json_annotation
|
||||
sha256: cb314f00b2488de7bc575207e54402cd2f92363f333a7933fd1b0631af226baa
|
||||
sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.6.0"
|
||||
version: "4.8.1"
|
||||
latlong2:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -1182,7 +1182,7 @@ packages:
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
unicode:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: unicode
|
||||
sha256: "0f69e46593d65245774d4f17125c6084d2c20b4e473a983f6e21b7d7762218f1"
|
||||
@ -1318,5 +1318,5 @@ packages:
|
||||
source: hosted
|
||||
version: "3.1.1"
|
||||
sdks:
|
||||
dart: ">=2.18.0 <3.0.0"
|
||||
dart: ">=2.19.0 <3.0.0"
|
||||
flutter: ">=3.7.0"
|
||||
|
||||
@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
version: 1.0.12+12
|
||||
|
||||
environment:
|
||||
sdk: ">=2.16.0 <3.0.0"
|
||||
sdk: ">=2.17.0 <3.0.0"
|
||||
|
||||
# Dependencies specify other packages that your package needs in order to work.
|
||||
# To automatically upgrade your package dependencies to the latest versions
|
||||
@ -75,6 +75,7 @@ dependencies:
|
||||
connectivity_plus: ^3.0.2
|
||||
flutter_map_tile_caching: ^6.2.0
|
||||
shared_preferences: ^2.0.15
|
||||
unicode: ^0.3.0
|
||||
|
||||
flutter_icons:
|
||||
android: true
|
||||
|
||||
BIN
web/favicon.png
BIN
web/favicon.png
Binary file not shown.
|
Before Width: | Height: | Size: 917 B |
Binary file not shown.
|
Before Width: | Height: | Size: 5.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 8.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB |
104
web/index.html
104
web/index.html
@ -1,104 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
If you are serving your web app in a path other than the root, change the
|
||||
href value below to reflect the base path you are serving from.
|
||||
|
||||
The path provided below has to start and end with a slash "/" in order for
|
||||
it to work correctly.
|
||||
|
||||
For more details:
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
|
||||
|
||||
This is a placeholder for base href that will be replaced by the value of
|
||||
the `--base-href` argument provided to `flutter build`.
|
||||
-->
|
||||
<base href="$FLUTTER_BASE_HREF">
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
|
||||
<meta name="description" content="A new Flutter project.">
|
||||
|
||||
<!-- iOS meta tags & icons -->
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<meta name="apple-mobile-web-app-title" content="rogapp">
|
||||
<link rel="apple-touch-icon" href="icons/Icon-192.png">
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="icon" type="image/png" href="favicon.png"/>
|
||||
|
||||
<title>岐阜ナビ</title>
|
||||
<link rel="manifest" href="manifest.json">
|
||||
</head>
|
||||
<body>
|
||||
<!-- This script installs service_worker.js to provide PWA functionality to
|
||||
application. For more information, see:
|
||||
https://developers.google.com/web/fundamentals/primers/service-workers -->
|
||||
<script>
|
||||
var serviceWorkerVersion = null;
|
||||
var scriptLoaded = false;
|
||||
function loadMainDartJs() {
|
||||
if (scriptLoaded) {
|
||||
return;
|
||||
}
|
||||
scriptLoaded = true;
|
||||
var scriptTag = document.createElement('script');
|
||||
scriptTag.src = 'main.dart.js';
|
||||
scriptTag.type = 'application/javascript';
|
||||
document.body.append(scriptTag);
|
||||
}
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
// Service workers are supported. Use them.
|
||||
window.addEventListener('load', function () {
|
||||
// Wait for registration to finish before dropping the <script> tag.
|
||||
// Otherwise, the browser will load the script multiple times,
|
||||
// potentially different versions.
|
||||
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
|
||||
navigator.serviceWorker.register(serviceWorkerUrl)
|
||||
.then((reg) => {
|
||||
function waitForActivation(serviceWorker) {
|
||||
serviceWorker.addEventListener('statechange', () => {
|
||||
if (serviceWorker.state == 'activated') {
|
||||
console.log('Installed new service worker.');
|
||||
loadMainDartJs();
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!reg.active && (reg.installing || reg.waiting)) {
|
||||
// No active web worker and we have installed or are installing
|
||||
// one for the first time. Simply wait for it to activate.
|
||||
waitForActivation(reg.installing || reg.waiting);
|
||||
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
|
||||
// When the app updates the serviceWorkerVersion changes, so we
|
||||
// need to ask the service worker to update.
|
||||
console.log('New service worker available.');
|
||||
reg.update();
|
||||
waitForActivation(reg.installing);
|
||||
} else {
|
||||
// Existing service worker is still good.
|
||||
console.log('Loading app from service worker.');
|
||||
loadMainDartJs();
|
||||
}
|
||||
});
|
||||
|
||||
// If service worker doesn't succeed in a reasonable amount of time,
|
||||
// fallback to plaint <script> tag.
|
||||
setTimeout(() => {
|
||||
if (!scriptLoaded) {
|
||||
console.warn(
|
||||
'Failed to load app from service worker. Falling back to plain <script> tag.',
|
||||
);
|
||||
loadMainDartJs();
|
||||
}
|
||||
}, 4000);
|
||||
});
|
||||
} else {
|
||||
// Service workers not supported. Just drop the <script> tag.
|
||||
loadMainDartJs();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,35 +0,0 @@
|
||||
{
|
||||
"name": "rogapp",
|
||||
"short_name": "rogapp",
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"background_color": "#0175C2",
|
||||
"theme_color": "#0175C2",
|
||||
"description": "A new Flutter project.",
|
||||
"orientation": "portrait-primary",
|
||||
"prefer_related_applications": false,
|
||||
"icons": [
|
||||
{
|
||||
"src": "icons/Icon-192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "icons/Icon-512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "icons/Icon-maskable-192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "icons/Icon-maskable-512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
}
|
||||
]
|
||||
}
|
||||
17
windows/.gitignore
vendored
17
windows/.gitignore
vendored
@ -1,17 +0,0 @@
|
||||
flutter/ephemeral/
|
||||
|
||||
# Visual Studio user-specific files.
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# Visual Studio build-related files.
|
||||
x64/
|
||||
x86/
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
@ -1,95 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(rogapp LANGUAGES CXX)
|
||||
|
||||
set(BINARY_NAME "rogapp")
|
||||
|
||||
cmake_policy(SET CMP0063 NEW)
|
||||
|
||||
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
|
||||
|
||||
# Configure build options.
|
||||
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
if(IS_MULTICONFIG)
|
||||
set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
|
||||
CACHE STRING "" FORCE)
|
||||
else()
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE "Debug" CACHE
|
||||
STRING "Flutter build mode" FORCE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
"Debug" "Profile" "Release")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
|
||||
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
|
||||
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
|
||||
# Use Unicode for all projects.
|
||||
add_definitions(-DUNICODE -D_UNICODE)
|
||||
|
||||
# Compilation settings that should be applied to most targets.
|
||||
function(APPLY_STANDARD_SETTINGS TARGET)
|
||||
target_compile_features(${TARGET} PUBLIC cxx_std_17)
|
||||
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
|
||||
target_compile_options(${TARGET} PRIVATE /EHsc)
|
||||
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
|
||||
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
|
||||
endfunction()
|
||||
|
||||
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
|
||||
|
||||
# Flutter library and tool build rules.
|
||||
add_subdirectory(${FLUTTER_MANAGED_DIR})
|
||||
|
||||
# Application build
|
||||
add_subdirectory("runner")
|
||||
|
||||
# Generated plugin build rules, which manage building the plugins and adding
|
||||
# them to the application.
|
||||
include(flutter/generated_plugins.cmake)
|
||||
|
||||
|
||||
# === Installation ===
|
||||
# Support files are copied into place next to the executable, so that it can
|
||||
# run in place. This is done instead of making a separate bundle (as on Linux)
|
||||
# so that building and running from within Visual Studio will work.
|
||||
set(BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>")
|
||||
# Make the "install" step default, as it's required to run.
|
||||
set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
|
||||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
|
||||
endif()
|
||||
|
||||
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
|
||||
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
if(PLUGIN_BUNDLED_LIBRARIES)
|
||||
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
|
||||
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
endif()
|
||||
|
||||
# Fully re-copy the assets directory on each build to avoid having stale files
|
||||
# from a previous install.
|
||||
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
|
||||
install(CODE "
|
||||
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
|
||||
" COMPONENT Runtime)
|
||||
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
|
||||
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
|
||||
|
||||
# Install the AOT library on non-Debug builds only.
|
||||
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
|
||||
CONFIGURATIONS Profile;Release
|
||||
COMPONENT Runtime)
|
||||
@ -1,103 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
|
||||
|
||||
# Configuration provided via flutter tool.
|
||||
include(${EPHEMERAL_DIR}/generated_config.cmake)
|
||||
|
||||
# TODO: Move the rest of this into files in ephemeral. See
|
||||
# https://github.com/flutter/flutter/issues/57146.
|
||||
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
|
||||
|
||||
# === Flutter Library ===
|
||||
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
|
||||
|
||||
# Published to parent scope for install step.
|
||||
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
|
||||
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
|
||||
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
|
||||
set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
|
||||
|
||||
list(APPEND FLUTTER_LIBRARY_HEADERS
|
||||
"flutter_export.h"
|
||||
"flutter_windows.h"
|
||||
"flutter_messenger.h"
|
||||
"flutter_plugin_registrar.h"
|
||||
"flutter_texture_registrar.h"
|
||||
)
|
||||
list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
|
||||
add_library(flutter INTERFACE)
|
||||
target_include_directories(flutter INTERFACE
|
||||
"${EPHEMERAL_DIR}"
|
||||
)
|
||||
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
|
||||
add_dependencies(flutter flutter_assemble)
|
||||
|
||||
# === Wrapper ===
|
||||
list(APPEND CPP_WRAPPER_SOURCES_CORE
|
||||
"core_implementations.cc"
|
||||
"standard_codec.cc"
|
||||
)
|
||||
list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
|
||||
list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
|
||||
"plugin_registrar.cc"
|
||||
)
|
||||
list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
|
||||
list(APPEND CPP_WRAPPER_SOURCES_APP
|
||||
"flutter_engine.cc"
|
||||
"flutter_view_controller.cc"
|
||||
)
|
||||
list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
|
||||
|
||||
# Wrapper sources needed for a plugin.
|
||||
add_library(flutter_wrapper_plugin STATIC
|
||||
${CPP_WRAPPER_SOURCES_CORE}
|
||||
${CPP_WRAPPER_SOURCES_PLUGIN}
|
||||
)
|
||||
apply_standard_settings(flutter_wrapper_plugin)
|
||||
set_target_properties(flutter_wrapper_plugin PROPERTIES
|
||||
POSITION_INDEPENDENT_CODE ON)
|
||||
set_target_properties(flutter_wrapper_plugin PROPERTIES
|
||||
CXX_VISIBILITY_PRESET hidden)
|
||||
target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
|
||||
target_include_directories(flutter_wrapper_plugin PUBLIC
|
||||
"${WRAPPER_ROOT}/include"
|
||||
)
|
||||
add_dependencies(flutter_wrapper_plugin flutter_assemble)
|
||||
|
||||
# Wrapper sources needed for the runner.
|
||||
add_library(flutter_wrapper_app STATIC
|
||||
${CPP_WRAPPER_SOURCES_CORE}
|
||||
${CPP_WRAPPER_SOURCES_APP}
|
||||
)
|
||||
apply_standard_settings(flutter_wrapper_app)
|
||||
target_link_libraries(flutter_wrapper_app PUBLIC flutter)
|
||||
target_include_directories(flutter_wrapper_app PUBLIC
|
||||
"${WRAPPER_ROOT}/include"
|
||||
)
|
||||
add_dependencies(flutter_wrapper_app flutter_assemble)
|
||||
|
||||
# === Flutter tool backend ===
|
||||
# _phony_ is a non-existent file to force this command to run every time,
|
||||
# since currently there's no way to get a full input/output list from the
|
||||
# flutter tool.
|
||||
set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
|
||||
set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
|
||||
add_custom_command(
|
||||
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
|
||||
${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
|
||||
${CPP_WRAPPER_SOURCES_APP}
|
||||
${PHONY_OUTPUT}
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
${FLUTTER_TOOL_ENVIRONMENT}
|
||||
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
|
||||
windows-x64 $<CONFIG>
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(flutter_assemble DEPENDS
|
||||
"${FLUTTER_LIBRARY}"
|
||||
${FLUTTER_LIBRARY_HEADERS}
|
||||
${CPP_WRAPPER_SOURCES_CORE}
|
||||
${CPP_WRAPPER_SOURCES_PLUGIN}
|
||||
${CPP_WRAPPER_SOURCES_APP}
|
||||
)
|
||||
@ -1,26 +0,0 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <connectivity_plus/connectivity_plus_windows_plugin.h>
|
||||
#include <geolocator_windows/geolocator_windows.h>
|
||||
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
||||
#include <share_plus/share_plus_windows_plugin_c_api.h>
|
||||
#include <url_launcher_windows/url_launcher_windows.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
ConnectivityPlusWindowsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
|
||||
GeolocatorWindowsRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("GeolocatorWindows"));
|
||||
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
||||
SharePlusWindowsPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
|
||||
UrlLauncherWindowsRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
||||
#define GENERATED_PLUGIN_REGISTRANT_
|
||||
|
||||
#include <flutter/plugin_registry.h>
|
||||
|
||||
// Registers Flutter plugins.
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry);
|
||||
|
||||
#endif // GENERATED_PLUGIN_REGISTRANT_
|
||||
@ -1,28 +0,0 @@
|
||||
#
|
||||
# Generated file, do not edit.
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
connectivity_plus
|
||||
geolocator_windows
|
||||
permission_handler_windows
|
||||
share_plus
|
||||
url_launcher_windows
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
)
|
||||
|
||||
set(PLUGIN_BUNDLED_LIBRARIES)
|
||||
|
||||
foreach(plugin ${FLUTTER_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
|
||||
endforeach(plugin)
|
||||
|
||||
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
|
||||
endforeach(ffi_plugin)
|
||||
@ -1,17 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(runner LANGUAGES CXX)
|
||||
|
||||
add_executable(${BINARY_NAME} WIN32
|
||||
"flutter_window.cpp"
|
||||
"main.cpp"
|
||||
"utils.cpp"
|
||||
"win32_window.cpp"
|
||||
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
|
||||
"Runner.rc"
|
||||
"runner.exe.manifest"
|
||||
)
|
||||
apply_standard_settings(${BINARY_NAME})
|
||||
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
|
||||
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
|
||||
add_dependencies(${BINARY_NAME} flutter_assemble)
|
||||
@ -1,121 +0,0 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#pragma code_page(65001)
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United States) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_APP_ICON ICON "resources\\app_icon.ico"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
#ifdef FLUTTER_BUILD_NUMBER
|
||||
#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
|
||||
#else
|
||||
#define VERSION_AS_NUMBER 1,0,0
|
||||
#endif
|
||||
|
||||
#ifdef FLUTTER_BUILD_NAME
|
||||
#define VERSION_AS_STRING #FLUTTER_BUILD_NAME
|
||||
#else
|
||||
#define VERSION_AS_STRING "1.0.0"
|
||||
#endif
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION_AS_NUMBER
|
||||
PRODUCTVERSION VERSION_AS_NUMBER
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS VS_FF_DEBUG
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS VOS__WINDOWS32
|
||||
FILETYPE VFT_APP
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904e4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "com.example" "\0"
|
||||
VALUE "FileDescription", "rogapp" "\0"
|
||||
VALUE "FileVersion", VERSION_AS_STRING "\0"
|
||||
VALUE "InternalName", "rogapp" "\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2022 com.example. All rights reserved." "\0"
|
||||
VALUE "OriginalFilename", "rogapp.exe" "\0"
|
||||
VALUE "ProductName", "rogapp" "\0"
|
||||
VALUE "ProductVersion", VERSION_AS_STRING "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
||||
#endif // English (United States) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
@ -1,61 +0,0 @@
|
||||
#include "flutter_window.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "flutter/generated_plugin_registrant.h"
|
||||
|
||||
FlutterWindow::FlutterWindow(const flutter::DartProject& project)
|
||||
: project_(project) {}
|
||||
|
||||
FlutterWindow::~FlutterWindow() {}
|
||||
|
||||
bool FlutterWindow::OnCreate() {
|
||||
if (!Win32Window::OnCreate()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RECT frame = GetClientArea();
|
||||
|
||||
// The size here must match the window dimensions to avoid unnecessary surface
|
||||
// creation / destruction in the startup path.
|
||||
flutter_controller_ = std::make_unique<flutter::FlutterViewController>(
|
||||
frame.right - frame.left, frame.bottom - frame.top, project_);
|
||||
// Ensure that basic setup of the controller was successful.
|
||||
if (!flutter_controller_->engine() || !flutter_controller_->view()) {
|
||||
return false;
|
||||
}
|
||||
RegisterPlugins(flutter_controller_->engine());
|
||||
SetChildContent(flutter_controller_->view()->GetNativeWindow());
|
||||
return true;
|
||||
}
|
||||
|
||||
void FlutterWindow::OnDestroy() {
|
||||
if (flutter_controller_) {
|
||||
flutter_controller_ = nullptr;
|
||||
}
|
||||
|
||||
Win32Window::OnDestroy();
|
||||
}
|
||||
|
||||
LRESULT
|
||||
FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
|
||||
WPARAM const wparam,
|
||||
LPARAM const lparam) noexcept {
|
||||
// Give Flutter, including plugins, an opportunity to handle window messages.
|
||||
if (flutter_controller_) {
|
||||
std::optional<LRESULT> result =
|
||||
flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
|
||||
lparam);
|
||||
if (result) {
|
||||
return *result;
|
||||
}
|
||||
}
|
||||
|
||||
switch (message) {
|
||||
case WM_FONTCHANGE:
|
||||
flutter_controller_->engine()->ReloadSystemFonts();
|
||||
break;
|
||||
}
|
||||
|
||||
return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
#ifndef RUNNER_FLUTTER_WINDOW_H_
|
||||
#define RUNNER_FLUTTER_WINDOW_H_
|
||||
|
||||
#include <flutter/dart_project.h>
|
||||
#include <flutter/flutter_view_controller.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "win32_window.h"
|
||||
|
||||
// A window that does nothing but host a Flutter view.
|
||||
class FlutterWindow : public Win32Window {
|
||||
public:
|
||||
// Creates a new FlutterWindow hosting a Flutter view running |project|.
|
||||
explicit FlutterWindow(const flutter::DartProject& project);
|
||||
virtual ~FlutterWindow();
|
||||
|
||||
protected:
|
||||
// Win32Window:
|
||||
bool OnCreate() override;
|
||||
void OnDestroy() override;
|
||||
LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
|
||||
LPARAM const lparam) noexcept override;
|
||||
|
||||
private:
|
||||
// The project to run.
|
||||
flutter::DartProject project_;
|
||||
|
||||
// The Flutter instance hosted by this window.
|
||||
std::unique_ptr<flutter::FlutterViewController> flutter_controller_;
|
||||
};
|
||||
|
||||
#endif // RUNNER_FLUTTER_WINDOW_H_
|
||||
@ -1,43 +0,0 @@
|
||||
#include <flutter/dart_project.h>
|
||||
#include <flutter/flutter_view_controller.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "flutter_window.h"
|
||||
#include "utils.h"
|
||||
|
||||
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
||||
_In_ wchar_t *command_line, _In_ int show_command) {
|
||||
// Attach to console when present (e.g., 'flutter run') or create a
|
||||
// new console when running with a debugger.
|
||||
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
|
||||
CreateAndAttachConsole();
|
||||
}
|
||||
|
||||
// Initialize COM, so that it is available for use in the library and/or
|
||||
// plugins.
|
||||
::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
||||
|
||||
flutter::DartProject project(L"data");
|
||||
|
||||
std::vector<std::string> command_line_arguments =
|
||||
GetCommandLineArguments();
|
||||
|
||||
project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
|
||||
|
||||
FlutterWindow window(project);
|
||||
Win32Window::Point origin(10, 10);
|
||||
Win32Window::Size size(1280, 720);
|
||||
if (!window.CreateAndShow(L"rogapp", origin, size)) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
window.SetQuitOnClose(true);
|
||||
|
||||
::MSG msg;
|
||||
while (::GetMessage(&msg, nullptr, 0, 0)) {
|
||||
::TranslateMessage(&msg);
|
||||
::DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
::CoUninitialize();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by Runner.rc
|
||||
//
|
||||
#define IDI_APP_ICON 101
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 33 KiB |
@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||
<!-- Windows 8.1 -->
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
||||
<!-- Windows 8 -->
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
||||
<!-- Windows 7 -->
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
||||
</application>
|
||||
</compatibility>
|
||||
</assembly>
|
||||
@ -1,64 +0,0 @@
|
||||
#include "utils.h"
|
||||
|
||||
#include <flutter_windows.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void CreateAndAttachConsole() {
|
||||
if (::AllocConsole()) {
|
||||
FILE *unused;
|
||||
if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
|
||||
_dup2(_fileno(stdout), 1);
|
||||
}
|
||||
if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
|
||||
_dup2(_fileno(stdout), 2);
|
||||
}
|
||||
std::ios::sync_with_stdio();
|
||||
FlutterDesktopResyncOutputStreams();
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> GetCommandLineArguments() {
|
||||
// Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
|
||||
int argc;
|
||||
wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
|
||||
if (argv == nullptr) {
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
std::vector<std::string> command_line_arguments;
|
||||
|
||||
// Skip the first argument as it's the binary name.
|
||||
for (int i = 1; i < argc; i++) {
|
||||
command_line_arguments.push_back(Utf8FromUtf16(argv[i]));
|
||||
}
|
||||
|
||||
::LocalFree(argv);
|
||||
|
||||
return command_line_arguments;
|
||||
}
|
||||
|
||||
std::string Utf8FromUtf16(const wchar_t* utf16_string) {
|
||||
if (utf16_string == nullptr) {
|
||||
return std::string();
|
||||
}
|
||||
int target_length = ::WideCharToMultiByte(
|
||||
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
|
||||
-1, nullptr, 0, nullptr, nullptr);
|
||||
if (target_length == 0) {
|
||||
return std::string();
|
||||
}
|
||||
std::string utf8_string;
|
||||
utf8_string.resize(target_length);
|
||||
int converted_length = ::WideCharToMultiByte(
|
||||
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
|
||||
-1, utf8_string.data(),
|
||||
target_length, nullptr, nullptr);
|
||||
if (converted_length == 0) {
|
||||
return std::string();
|
||||
}
|
||||
return utf8_string;
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
#ifndef RUNNER_UTILS_H_
|
||||
#define RUNNER_UTILS_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// Creates a console for the process, and redirects stdout and stderr to
|
||||
// it for both the runner and the Flutter library.
|
||||
void CreateAndAttachConsole();
|
||||
|
||||
// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
|
||||
// encoded in UTF-8. Returns an empty std::string on failure.
|
||||
std::string Utf8FromUtf16(const wchar_t* utf16_string);
|
||||
|
||||
// Gets the command line arguments passed in as a std::vector<std::string>,
|
||||
// encoded in UTF-8. Returns an empty std::vector<std::string> on failure.
|
||||
std::vector<std::string> GetCommandLineArguments();
|
||||
|
||||
#endif // RUNNER_UTILS_H_
|
||||
@ -1,245 +0,0 @@
|
||||
#include "win32_window.h"
|
||||
|
||||
#include <flutter_windows.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
|
||||
|
||||
// The number of Win32Window objects that currently exist.
|
||||
static int g_active_window_count = 0;
|
||||
|
||||
using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd);
|
||||
|
||||
// Scale helper to convert logical scaler values to physical using passed in
|
||||
// scale factor
|
||||
int Scale(int source, double scale_factor) {
|
||||
return static_cast<int>(source * scale_factor);
|
||||
}
|
||||
|
||||
// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module.
|
||||
// This API is only needed for PerMonitor V1 awareness mode.
|
||||
void EnableFullDpiSupportIfAvailable(HWND hwnd) {
|
||||
HMODULE user32_module = LoadLibraryA("User32.dll");
|
||||
if (!user32_module) {
|
||||
return;
|
||||
}
|
||||
auto enable_non_client_dpi_scaling =
|
||||
reinterpret_cast<EnableNonClientDpiScaling*>(
|
||||
GetProcAddress(user32_module, "EnableNonClientDpiScaling"));
|
||||
if (enable_non_client_dpi_scaling != nullptr) {
|
||||
enable_non_client_dpi_scaling(hwnd);
|
||||
FreeLibrary(user32_module);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// Manages the Win32Window's window class registration.
|
||||
class WindowClassRegistrar {
|
||||
public:
|
||||
~WindowClassRegistrar() = default;
|
||||
|
||||
// Returns the singleton registar instance.
|
||||
static WindowClassRegistrar* GetInstance() {
|
||||
if (!instance_) {
|
||||
instance_ = new WindowClassRegistrar();
|
||||
}
|
||||
return instance_;
|
||||
}
|
||||
|
||||
// Returns the name of the window class, registering the class if it hasn't
|
||||
// previously been registered.
|
||||
const wchar_t* GetWindowClass();
|
||||
|
||||
// Unregisters the window class. Should only be called if there are no
|
||||
// instances of the window.
|
||||
void UnregisterWindowClass();
|
||||
|
||||
private:
|
||||
WindowClassRegistrar() = default;
|
||||
|
||||
static WindowClassRegistrar* instance_;
|
||||
|
||||
bool class_registered_ = false;
|
||||
};
|
||||
|
||||
WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr;
|
||||
|
||||
const wchar_t* WindowClassRegistrar::GetWindowClass() {
|
||||
if (!class_registered_) {
|
||||
WNDCLASS window_class{};
|
||||
window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||
window_class.lpszClassName = kWindowClassName;
|
||||
window_class.style = CS_HREDRAW | CS_VREDRAW;
|
||||
window_class.cbClsExtra = 0;
|
||||
window_class.cbWndExtra = 0;
|
||||
window_class.hInstance = GetModuleHandle(nullptr);
|
||||
window_class.hIcon =
|
||||
LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
|
||||
window_class.hbrBackground = 0;
|
||||
window_class.lpszMenuName = nullptr;
|
||||
window_class.lpfnWndProc = Win32Window::WndProc;
|
||||
RegisterClass(&window_class);
|
||||
class_registered_ = true;
|
||||
}
|
||||
return kWindowClassName;
|
||||
}
|
||||
|
||||
void WindowClassRegistrar::UnregisterWindowClass() {
|
||||
UnregisterClass(kWindowClassName, nullptr);
|
||||
class_registered_ = false;
|
||||
}
|
||||
|
||||
Win32Window::Win32Window() {
|
||||
++g_active_window_count;
|
||||
}
|
||||
|
||||
Win32Window::~Win32Window() {
|
||||
--g_active_window_count;
|
||||
Destroy();
|
||||
}
|
||||
|
||||
bool Win32Window::CreateAndShow(const std::wstring& title,
|
||||
const Point& origin,
|
||||
const Size& size) {
|
||||
Destroy();
|
||||
|
||||
const wchar_t* window_class =
|
||||
WindowClassRegistrar::GetInstance()->GetWindowClass();
|
||||
|
||||
const POINT target_point = {static_cast<LONG>(origin.x),
|
||||
static_cast<LONG>(origin.y)};
|
||||
HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
|
||||
UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
|
||||
double scale_factor = dpi / 96.0;
|
||||
|
||||
HWND window = CreateWindow(
|
||||
window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
||||
Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
|
||||
Scale(size.width, scale_factor), Scale(size.height, scale_factor),
|
||||
nullptr, nullptr, GetModuleHandle(nullptr), this);
|
||||
|
||||
if (!window) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return OnCreate();
|
||||
}
|
||||
|
||||
// static
|
||||
LRESULT CALLBACK Win32Window::WndProc(HWND const window,
|
||||
UINT const message,
|
||||
WPARAM const wparam,
|
||||
LPARAM const lparam) noexcept {
|
||||
if (message == WM_NCCREATE) {
|
||||
auto window_struct = reinterpret_cast<CREATESTRUCT*>(lparam);
|
||||
SetWindowLongPtr(window, GWLP_USERDATA,
|
||||
reinterpret_cast<LONG_PTR>(window_struct->lpCreateParams));
|
||||
|
||||
auto that = static_cast<Win32Window*>(window_struct->lpCreateParams);
|
||||
EnableFullDpiSupportIfAvailable(window);
|
||||
that->window_handle_ = window;
|
||||
} else if (Win32Window* that = GetThisFromHandle(window)) {
|
||||
return that->MessageHandler(window, message, wparam, lparam);
|
||||
}
|
||||
|
||||
return DefWindowProc(window, message, wparam, lparam);
|
||||
}
|
||||
|
||||
LRESULT
|
||||
Win32Window::MessageHandler(HWND hwnd,
|
||||
UINT const message,
|
||||
WPARAM const wparam,
|
||||
LPARAM const lparam) noexcept {
|
||||
switch (message) {
|
||||
case WM_DESTROY:
|
||||
window_handle_ = nullptr;
|
||||
Destroy();
|
||||
if (quit_on_close_) {
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_DPICHANGED: {
|
||||
auto newRectSize = reinterpret_cast<RECT*>(lparam);
|
||||
LONG newWidth = newRectSize->right - newRectSize->left;
|
||||
LONG newHeight = newRectSize->bottom - newRectSize->top;
|
||||
|
||||
SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth,
|
||||
newHeight, SWP_NOZORDER | SWP_NOACTIVATE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
case WM_SIZE: {
|
||||
RECT rect = GetClientArea();
|
||||
if (child_content_ != nullptr) {
|
||||
// Size and position the child window.
|
||||
MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left,
|
||||
rect.bottom - rect.top, TRUE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
case WM_ACTIVATE:
|
||||
if (child_content_ != nullptr) {
|
||||
SetFocus(child_content_);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return DefWindowProc(window_handle_, message, wparam, lparam);
|
||||
}
|
||||
|
||||
void Win32Window::Destroy() {
|
||||
OnDestroy();
|
||||
|
||||
if (window_handle_) {
|
||||
DestroyWindow(window_handle_);
|
||||
window_handle_ = nullptr;
|
||||
}
|
||||
if (g_active_window_count == 0) {
|
||||
WindowClassRegistrar::GetInstance()->UnregisterWindowClass();
|
||||
}
|
||||
}
|
||||
|
||||
Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept {
|
||||
return reinterpret_cast<Win32Window*>(
|
||||
GetWindowLongPtr(window, GWLP_USERDATA));
|
||||
}
|
||||
|
||||
void Win32Window::SetChildContent(HWND content) {
|
||||
child_content_ = content;
|
||||
SetParent(content, window_handle_);
|
||||
RECT frame = GetClientArea();
|
||||
|
||||
MoveWindow(content, frame.left, frame.top, frame.right - frame.left,
|
||||
frame.bottom - frame.top, true);
|
||||
|
||||
SetFocus(child_content_);
|
||||
}
|
||||
|
||||
RECT Win32Window::GetClientArea() {
|
||||
RECT frame;
|
||||
GetClientRect(window_handle_, &frame);
|
||||
return frame;
|
||||
}
|
||||
|
||||
HWND Win32Window::GetHandle() {
|
||||
return window_handle_;
|
||||
}
|
||||
|
||||
void Win32Window::SetQuitOnClose(bool quit_on_close) {
|
||||
quit_on_close_ = quit_on_close;
|
||||
}
|
||||
|
||||
bool Win32Window::OnCreate() {
|
||||
// No-op; provided for subclasses.
|
||||
return true;
|
||||
}
|
||||
|
||||
void Win32Window::OnDestroy() {
|
||||
// No-op; provided for subclasses.
|
||||
}
|
||||
@ -1,98 +0,0 @@
|
||||
#ifndef RUNNER_WIN32_WINDOW_H_
|
||||
#define RUNNER_WIN32_WINDOW_H_
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
// A class abstraction for a high DPI-aware Win32 Window. Intended to be
|
||||
// inherited from by classes that wish to specialize with custom
|
||||
// rendering and input handling
|
||||
class Win32Window {
|
||||
public:
|
||||
struct Point {
|
||||
unsigned int x;
|
||||
unsigned int y;
|
||||
Point(unsigned int x, unsigned int y) : x(x), y(y) {}
|
||||
};
|
||||
|
||||
struct Size {
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
Size(unsigned int width, unsigned int height)
|
||||
: width(width), height(height) {}
|
||||
};
|
||||
|
||||
Win32Window();
|
||||
virtual ~Win32Window();
|
||||
|
||||
// Creates and shows a win32 window with |title| and position and size using
|
||||
// |origin| and |size|. New windows are created on the default monitor. Window
|
||||
// sizes are specified to the OS in physical pixels, hence to ensure a
|
||||
// consistent size to will treat the width height passed in to this function
|
||||
// as logical pixels and scale to appropriate for the default monitor. Returns
|
||||
// true if the window was created successfully.
|
||||
bool CreateAndShow(const std::wstring& title,
|
||||
const Point& origin,
|
||||
const Size& size);
|
||||
|
||||
// Release OS resources associated with window.
|
||||
void Destroy();
|
||||
|
||||
// Inserts |content| into the window tree.
|
||||
void SetChildContent(HWND content);
|
||||
|
||||
// Returns the backing Window handle to enable clients to set icon and other
|
||||
// window properties. Returns nullptr if the window has been destroyed.
|
||||
HWND GetHandle();
|
||||
|
||||
// If true, closing this window will quit the application.
|
||||
void SetQuitOnClose(bool quit_on_close);
|
||||
|
||||
// Return a RECT representing the bounds of the current client area.
|
||||
RECT GetClientArea();
|
||||
|
||||
protected:
|
||||
// Processes and route salient window messages for mouse handling,
|
||||
// size change and DPI. Delegates handling of these to member overloads that
|
||||
// inheriting classes can handle.
|
||||
virtual LRESULT MessageHandler(HWND window,
|
||||
UINT const message,
|
||||
WPARAM const wparam,
|
||||
LPARAM const lparam) noexcept;
|
||||
|
||||
// Called when CreateAndShow is called, allowing subclass window-related
|
||||
// setup. Subclasses should return false if setup fails.
|
||||
virtual bool OnCreate();
|
||||
|
||||
// Called when Destroy is called.
|
||||
virtual void OnDestroy();
|
||||
|
||||
private:
|
||||
friend class WindowClassRegistrar;
|
||||
|
||||
// OS callback called by message pump. Handles the WM_NCCREATE message which
|
||||
// is passed when the non-client area is being created and enables automatic
|
||||
// non-client DPI scaling so that the non-client area automatically
|
||||
// responsponds to changes in DPI. All other messages are handled by
|
||||
// MessageHandler.
|
||||
static LRESULT CALLBACK WndProc(HWND const window,
|
||||
UINT const message,
|
||||
WPARAM const wparam,
|
||||
LPARAM const lparam) noexcept;
|
||||
|
||||
// Retrieves a class instance pointer for |window|
|
||||
static Win32Window* GetThisFromHandle(HWND const window) noexcept;
|
||||
|
||||
bool quit_on_close_ = false;
|
||||
|
||||
// window handle for top level window.
|
||||
HWND window_handle_ = nullptr;
|
||||
|
||||
// window handle for hosted content.
|
||||
HWND child_content_ = nullptr;
|
||||
};
|
||||
|
||||
#endif // RUNNER_WIN32_WINDOW_H_
|
||||
Reference in New Issue
Block a user