大幅変更&環境バージョンアップ

This commit is contained in:
2024-08-22 14:35:09 +09:00
parent 56e9861c7a
commit dc58dc0584
446 changed files with 29645 additions and 8315 deletions

27
lib/model/auth_user.dart Normal file
View File

@ -0,0 +1,27 @@
// プロパティの型がString?やint?などのオプショナル型になっています。
// これらのプロパティが常に値を持つことが保証されている場合は、非オプショナル型を使用することで、不要なnullチェックを回避できます。
//
class AuthUser {
AuthUser();
//AuthUser.from({required this.id, required this.email, required this.is_rogaining, required this.group, required this.zekken_number, required this.event_code, required this.team_name});
AuthUser.fromMap(Map<String, dynamic> map)
: id = int.parse(map["id"].toString()),
email = map["email"].toString(),
is_rogaining = bool.parse(map["is_rogaining"].toString()),
group = map["group"].toString(),
zekken_number = map["zekken_number"].toString(),
event_code = map["event_code"].toString(),
team_name = map["team_name"].toString(),
auth_token = map["token"];
int? id;
String? email;
bool? is_rogaining;
String? group;
String? zekken_number;
String? event_code;
String? team_name;
String? auth_token;
}

80
lib/model/category.dart Normal file
View File

@ -0,0 +1,80 @@
// lib/models/category.dart
class NewCategory {
final int id;
final String categoryName;
final int categoryNumber;
final Duration duration;
final int numOfMember;
final bool family;
final bool female;
final String? time;
NewCategory({
required this.id,
required this.categoryName,
this.time,
required this.categoryNumber,
required this.duration,
required this.numOfMember,
required this.family,
required this.female,
});
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is NewCategory &&
runtimeType == other.runtimeType &&
id == other.id;
@override
int get hashCode => id.hashCode;
factory NewCategory.fromJson(Map<String, dynamic> json) {
final fullCategoryName = json['category_name'] as String;
final parts = fullCategoryName.split('-');
final baseName = parts[0].trim();
final time = parts.length > 1 ? parts[1].trim() : null;
return NewCategory(
id: json['id'] ?? 0,
categoryName: json['category_name'] ?? 'Unknown Category',
time: time,
categoryNumber: json['category_number'] ?? 0,
duration: parseDuration(json['duration']),
numOfMember: json['num_of_member'] ?? 1,
family: json['family'] ?? false,
female: json['female'] ?? false,
);
}
String get baseCategory => categoryName.split('-')[0].trim();
static Duration parseDuration(String s) {
int hours = 0;
int minutes = 0;
int micros;
List<String> parts = s.split(':');
if (parts.length > 2) {
hours = int.parse(parts[parts.length - 3]);
}
if (parts.length > 1) {
minutes = int.parse(parts[parts.length - 2]);
}
micros = (double.parse(parts[parts.length - 1]) * 1000000).round();
return Duration(hours: hours, minutes: minutes, microseconds: micros);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'category_name': categoryName,
'category_number': categoryNumber,
'duration': duration.inSeconds,
'num_of_member': numOfMember,
'family': family,
'female': female,
};
}
}

View File

@ -1,113 +1,138 @@
// プロパティの型がString?やint?などのオプショナル型になっています。
// これらのプロパティが常に値を持つことが保証されている場合は、非オプショナル型を使用することで、不要なnullチェックを回避できます。
//
class Destination {
String? name;
String? address;
String? phone;
String? email;
String? webcontents;
String? videos;
String? category;
int? series;
double? lat;
double? lon;
String? sub_loc_id;
int? location_id;
int? list_order;
String? photos;
double? checkin_radious;
int? auto_checkin;
bool? selected = false;
bool? checkedin = false;
double? cp;
double? checkin_point;
double? buy_point;
int? hidden_location;
String? name;
String? address;
String? phone;
String? email;
String? webcontents;
String? videos;
String? category;
int? series;
double? lat;
double? lon;
String? sub_loc_id;
int? location_id;
int? list_order;
String? photos;
double? checkin_radious;
int? auto_checkin;
bool? selected = false;
bool? checkedin = false;
double? cp;
double? checkin_point;
double? buy_point;
int? hidden_location;
String? checkin_image;
String? buypoint_image;
bool forced_checkin = false;
int recipt_times = 0;
String? tags;
Destination({
this.name,
this.address,
this.phone,
this.email,
this.webcontents,
this.videos,
this.category,
this.series,
this.lat,
this.lon,
this.sub_loc_id,
this.location_id,
this.list_order,
this.photos,
this.checkin_radious,
this.auto_checkin,
this.selected,
this.checkedin,
this.cp,
this.checkin_point,
this.buy_point,
this.hidden_location
});
bool use_qr_code = false; // QR code を使用するかどうか。default=false
factory Destination.fromMap(Map<String, dynamic> json) {
Destination(
{this.name,
this.address,
this.phone,
this.email,
this.webcontents,
this.videos,
this.category,
this.series,
this.lat,
this.lon,
this.sub_loc_id,
this.location_id,
this.list_order,
this.photos,
this.checkin_radious,
this.auto_checkin,
this.selected,
this.checkedin,
this.cp,
this.checkin_point,
this.buy_point,
this.hidden_location,
this.checkin_image,
this.buypoint_image,
this.forced_checkin = false,
this.recipt_times = 0,
this.tags}); //, ... use_qr_code をDBに追加したらオープン
// this.use_qr_code = false});
bool selec = json['selected'] == 0 ? false : true;
bool checkin = json['checkedin'] == 0 ? false : true;
factory Destination.fromMap(Map<String, dynamic> json) {
bool selec = json['selected'] == 0 ? false : true;
bool checkin = json['checkedin'] == 0 ? false : true;
bool forcedCheckin = json['forced_checkin'] == 0 ? false : true;
bool useQrCode = json['use_qr_code'] == 1 ? true : false;
//print("-----tags model----- ${json}");
return Destination(
name: json['name'],
address: json['address'],
phone: json['phone'],
email: json['email'],
webcontents: json['webcontents'],
videos: json['videos'],
category: json['category'],
series: json['series'],
lat: json['lat'],
lon: json['lon'],
sub_loc_id : json['sub_loc_id'],
location_id: json['location_id'],
list_order: json['list_order'],
photos: json['photos'],
checkin_radious: json['checkin_radious'],
auto_checkin:json['auto_checkin'],
selected: selec,
checkedin: checkin,
cp: json['cp'],
checkin_point: json['checkin_point'],
buy_point: json['buy_point'],
hidden_location: json['hidden_location']
);
}
return Destination(
name: json['name'],
address: json['address'],
phone: json['phone'],
email: json['email'],
webcontents: json['webcontents'],
videos: json['videos'],
category: json['category'],
series: json['series'],
lat: json['lat'],
lon: json['lon'],
sub_loc_id: json['sub_loc_id'],
location_id: json['location_id'],
list_order: json['list_order'],
photos: json['photos'],
checkin_radious: json['checkin_radious'],
auto_checkin: json['auto_checkin'],
selected: selec,
checkedin: checkin,
cp: json['cp'],
checkin_point: json['checkin_point'],
buy_point: json['buy_point'],
hidden_location: json['hidden_location'],
checkin_image: json['checkin_image'],
buypoint_image: json["buypoint_image"],
forced_checkin: forcedCheckin,
recipt_times: json["recipt_times"],
tags: json["tags"] ); //,
// use_qr_code: useQrCode);
}
Map<String, dynamic> toMap(){
int sel = selected == false ? 0 : 1;
int check = checkedin == false ? 0 : 1;
return {
'name':name,
'address': address,
'phone': phone,
'email': email,
'webcontents': webcontents,
'videos': videos,
'category':category,
'series':series,
'lat':lat,
'lon':lon,
'sub_loc_id': sub_loc_id,
'location_id':location_id,
'list_order':list_order,
'photos':photos,
'checkin_radious': checkin_radious,
'auto_checkin': auto_checkin,
'selected': sel,
'checkedin': check,
'cp' : cp,
'checkin_point' : checkin_point,
'buy_point' : buy_point,
'hidden_location' : hidden_location
};
}
}
Map<String, dynamic> toMap() {
int sel = selected == false ? 0 : 1;
int check = checkedin == false ? 0 : 1;
int forcedCheckin = forced_checkin == false ? 0 : 1;
return {
'name': name,
'address': address,
'phone': phone,
'email': email,
'webcontents': webcontents,
'videos': videos,
'category': category,
'series': series,
'lat': lat,
'lon': lon,
'sub_loc_id': sub_loc_id,
'location_id': location_id,
'list_order': list_order,
'photos': photos,
'checkin_radious': checkin_radious,
'auto_checkin': auto_checkin,
'selected': sel,
'checkedin': check,
'cp': cp,
'checkin_point': checkin_point,
'buy_point': buy_point,
'hidden_location': hidden_location,
'checkin_image': checkin_image,
'buypoint_image': buypoint_image,
'forced_checkin': forcedCheckin,
'recipt_times': recipt_times,
'tags': tags //,
//'use_qr_code': use_qr_code
};
}
}

50
lib/model/entry.dart Normal file
View File

@ -0,0 +1,50 @@
// lib/models/entry.dart
import 'event.dart';
import 'team.dart';
import 'category.dart';
class Entry {
final int id;
final Team team;
final Event event;
final NewCategory category;
final DateTime? date;
final int zekkenNumber; // 新しく追加
final String owner;
Entry({
required this.id,
required this.team,
required this.event,
required this.category,
required this.date,
required this.zekkenNumber,
required this.owner,
});
factory Entry.fromJson(Map<String, dynamic> json) {
return Entry(
id: json['id'],
team: Team.fromJson(json['team']),
event: Event.fromJson(json['event']),
category: NewCategory.fromJson(json['category']),
date: json['date'] != null
? DateTime.tryParse(json['date'])
: null,
zekkenNumber: json['zekken_number'], // 新しく追加
owner: json['owner'] is Map ? json['owner']['name'] ?? '' : json['owner'] ?? '',
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'team': team.toJson(),
'event': event.toJson(),
'category': category.toJson(),
'date': date?.toIso8601String(),
'zekken_number': zekkenNumber, // 新しく追加
'owner': owner,
};
}
}

40
lib/model/event.dart Normal file
View File

@ -0,0 +1,40 @@
// lib/models/event.dart
class Event {
final int id;
final String eventName;
final DateTime startDatetime;
final DateTime endDatetime;
final DateTime deadlineDateTime; // 新しく追加
Event({
required this.id,
required this.eventName,
required this.startDatetime,
required this.endDatetime,
required this.deadlineDateTime,
});
factory Event.fromJson(Map<String, dynamic> json) {
final endDatetime = DateTime.parse(json['end_datetime']);
return Event(
id: json['id'],
eventName: json['event_name'],
startDatetime: DateTime.parse(json['start_datetime']),
endDatetime: DateTime.parse(json['end_datetime']),
deadlineDateTime: json['deadline_datetime'] != null
? DateTime.parse(json['deadline_datetime'])
: endDatetime.subtract(const Duration(days: 7)), // 仮の実装
// deadlineDateTime: DateTime.parse(json['deadline_datetime']),
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'event_name': eventName,
'start_datetime': startDatetime.toIso8601String(),
'end_datetime': endDatetime.toIso8601String(),
};
}
}

View File

@ -0,0 +1,8 @@
enum LocationState { noGps, notInCheckin, withinCheckin }
enum GameState { notStarted, startedNotCounted, startedCounted, nodeGoal }
class GameInsStatetance {
LocationState locationState = LocationState.noGps;
GameState gameState = GameState.notStarted;
}

47
lib/model/gps_data.dart Normal file
View File

@ -0,0 +1,47 @@
class GpsData {
int id;
String team_name;
String event_code;
double lat;
double lon;
int is_checkin;
int created_at;
int is_synced;
GpsData({
required this.id,
required this.team_name,
required this.event_code,
required this.lat,
required this.lon,
required this.created_at,
this.is_checkin = 0,
this.is_synced = 0,
});
factory GpsData.fromMap(Map<String, dynamic> json) {
return GpsData(
id: json["id"],
team_name: json["team_name"],
event_code: json["event_code"],
lat: json["lat"],
lon: json["lon"],
is_checkin: json["is_checkin"],
created_at: json["created_at"],
is_synced: json["is_synced"] ?? 0,
);
}
Map<String, dynamic> toMap() {
return {
'id': id,
'team_name': team_name,
'event_code': event_code,
'lat': lat,
'lon': lon,
'is_checkin': is_checkin,
'created_at': created_at,
'is_synced': is_synced,
};
}
}

View File

@ -0,0 +1,6 @@
import 'package:flutter_map/flutter_map.dart';
class MapStateInstance {
MapController? mapController;
LatLngBounds? currentBounds;
}

51
lib/model/team.dart Normal file
View File

@ -0,0 +1,51 @@
// lib/models/team.dart
import 'category.dart';
import 'user.dart';
class Team {
final int id;
// final String zekkenNumber;
final String teamName;
final NewCategory category;
final User owner;
List<User> members; // membersフィールドを追加
Team({
required this.id,
// required this.zekkenNumber,
required this.teamName,
required this.category,
required this.owner,
this.members = const [], // デフォルト値を空のリストに設定
});
factory Team.fromJson(Map<String, dynamic> json) {
return Team(
id: json['id'] ?? 0,
//zekkenNumber: json['zekken_number'] ?? 'Unknown',
teamName: json['team_name'] ?? 'Unknown Team',
category: json['category'] != null
? NewCategory.fromJson(json['category'])
: NewCategory(id: 0, categoryName: 'Unknown', categoryNumber: 0, duration: Duration.zero, numOfMember: 1, family: false, female: false),
owner: json['owner'] != null
? User.fromJson(json['owner'])
: User(id: 0, email: 'unknown@example.com', firstname: 'Unknown', lastname: 'User', dateOfBirth: null, female: false, isActive: false),
members: json['members'] != null // membersフィールドを解析
? List<User>.from(json['members'].map((x) => User.fromJson(x)))
: [],
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
//'zekken_number': zekkenNumber,
'team_name': teamName,
'category': category.toJson(),
'owner': owner.toJson(),
'members': members.map((member) => member.toJson()).toList(), // membersフィールドをJSONに変換
};
}
}

47
lib/model/user.dart Normal file
View File

@ -0,0 +1,47 @@
// lib/models/user.dart
class User {
final int? id;
final String? email;
final String firstname;
final String lastname;
final DateTime? dateOfBirth;
late final bool female;
final bool isActive;
User({
this.id,
this.email,
required this.firstname,
required this.lastname,
this.dateOfBirth,
required this.female,
required this.isActive,
});
factory User.fromJson(Map<String, dynamic> json) {
return User(
id: json['id'],
email: json['email'],
firstname: json['firstname'] ?? 'Unknown',
lastname: json['lastname'] ?? 'Unknown',
dateOfBirth: json['date_of_birth'] != null
? DateTime.tryParse(json['date_of_birth'])
: null,
female: json['female'] ?? false,
isActive: json['is_active'] ?? false,
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'email': email,
'firstname': firstname,
'lastname': lastname,
'date_of_birth': dateOfBirth?.toIso8601String(),
'female': female,
'is_active': isActive,
};
}
}