@@ -42,9 +42,15 @@ Map<String, dynamic> _convertMap(Map<dynamic, dynamic> originalMap) {
4242class UserModel {
4343 final String id;
4444 final String name;
45+ final String learnerBirth;
46+ final String learnerHabit;
4547 final LatLng location;
4648
47- UserModel ({required this .id, required this .name, required this .location});
49+ UserModel ({required this .id,
50+ required this .name,
51+ required this .learnerBirth,
52+ required this .learnerHabit,
53+ required this .location});
4854
4955 factory UserModel .fromFirebase (String id, Map <String , dynamic > data) {
5056 print ('data: $data ' );
@@ -56,6 +62,8 @@ class UserModel {
5662 return UserModel (
5763 id: id,
5864 name: data['name' ] ?? 'Unknown User' ,
65+ learnerBirth: data['learner_birth' ] ?? '1980' ,
66+ learnerHabit: data['learner_habit' ] ?? '未知' ,
5967 location: LatLng (
6068 _parseCoordinate (coordinates[0 ].trim ()),
6169 _parseCoordinate (coordinates[1 ].trim ()),
@@ -238,6 +246,11 @@ class _MapScreenState extends State<MapScreen> {
238246 }
239247
240248 Widget _buildUserInfoSheet (UserModel user) {
249+
250+ final learnerBirth = user.learnerBirth;
251+ final currentYear = DateTime .now ().year;
252+ final age = currentYear - int .parse (learnerBirth);
253+
241254 return Container (
242255 padding: const EdgeInsets .all (16.0 ),
243256 child: Column (
@@ -250,8 +263,15 @@ class _MapScreenState extends State<MapScreen> {
250263 ),
251264 const SizedBox (height: 8 ),
252265 // You can fetch more user details here if needed
253- Text ('ID: ${user .id }' ),
254- Text ('座標: ${user .location .latitude .toStringAsFixed (4 )}, ${user .location .longitude .toStringAsFixed (4 )}' ),
266+ // Text('ID: ${user.id}'),
267+ // Text('座標: ${user.location.latitude.toStringAsFixed(4)}, ${user.location.longitude.toStringAsFixed(4)}'),
268+
269+ // 用learner_birth(西元年) 來計算年齡
270+ Text ('年齡:約 $age 歲' ),
271+
272+ Text ('興趣: ${user .learnerHabit }' ),
273+
274+
255275 const SizedBox (height: 16 ),
256276 ElevatedButton (
257277 child: const Text ('查看完整資料' ),
0 commit comments