Skip to content

Commit 4685107

Browse files
committed
Fixed bug
1 parent 19ae404 commit 4685107

File tree

5 files changed

+25
-41
lines changed

5 files changed

+25
-41
lines changed

lib/add_habit/habit_edit_page.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,7 @@ class _HabitEditPageState extends State<HabitEditPage>
423423
.toList(),
424424
createTime: DateTime.now().millisecondsSinceEpoch,
425425
completed: false,
426-
records: [],
427-
userId: SessionUtils.sharedInstance().getUserId());
426+
records: []);
428427
await createAlarmEvents(remindTimes, habit.name);
429428
BlocProvider.of<HabitsBloc>(context).add(HabitsAdd(habit));
430429
FlashHelper.toast(context, '保存成功');

lib/habit_progress/week_month_chart.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ class _WeekMonthChartState extends State<WeekMonthChart>
333333
}),
334334
touchCallback: (event, barTouchResponse) {
335335
setState(() {
336-
if (barTouchResponse.spot != null) {
337-
touchedIndex = barTouchResponse.spot.touchedBarGroupIndex;
336+
if (barTouchResponse?.spot != null) {
337+
touchedIndex = barTouchResponse.spot?.touchedBarGroupIndex;
338338
} else {
339339
touchedIndex = -1;
340340
}

lib/login/login_page.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
44
import 'package:timefly/models/user.dart';
55
import 'package:timefly/utils/flash_helper.dart';
66
import 'package:timefly/utils/system_util.dart';
7+
import 'package:timefly/utils/uuid.dart';
78
import 'package:timefly/widget/custom_edit_field.dart';
89

910
import '../app_theme.dart';
@@ -166,7 +167,9 @@ class _LoginPageState extends State<LoginPage>
166167
if (timer != null && timer.isActive) {
167168
return;
168169
}
169-
170+
Future.delayed(Duration(seconds: 2), () {
171+
FlashHelper.toast(context, "Send success");
172+
});
170173
},
171174
onDoubleTap: () {},
172175
child: Container(
@@ -205,7 +208,10 @@ class _LoginPageState extends State<LoginPage>
205208
)),
206209
child: GestureDetector(
207210
onTap: () {
208-
211+
FlashHelper.toast(context, '登录成功');
212+
User user = User(Uuid().generateV4(), '', phone);
213+
SessionUtils.sharedInstance().login(user);
214+
Navigator.of(context).pop();
209215
},
210216
onDoubleTap: () {},
211217
child: Container(

lib/models/habit.dart

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,34 @@ import 'package:equatable/equatable.dart';
66
///
77
// ignore: must_be_immutable
88
class HabitRecord extends Equatable {
9-
final String objectId;
10-
final String userId;
119
final String habitId;
1210
final int time;
1311
final String content;
1412

15-
HabitRecord(
16-
{this.time, this.content, this.habitId, this.userId, this.objectId});
13+
HabitRecord({this.time, this.content, this.habitId});
1714

1815
@override
1916
String toString() {
20-
return 'HabitRecord{time: $time, content: $content, habitId: $habitId, userId: $userId, objectId: $objectId}';
17+
return 'HabitRecord{time: $time, content: $content, habitId: $habitId}';
2118
}
2219

2320
static HabitRecord fromJson(Map<String, dynamic> json) {
2421
return HabitRecord(
2522
habitId: json['habitId']?.toString(),
2623
time: json["time"]?.toInt(),
27-
content: json["content"]?.toString(),
28-
userId: json['userId']?.toString(),
29-
objectId: json['objectId']?.toString());
24+
content: json["content"]?.toString());
3025
}
3126

3227
Map<String, dynamic> toJson() {
3328
final Map<String, dynamic> data = Map<String, dynamic>();
3429
data['habitId'] = habitId;
3530
data["time"] = time;
3631
data["content"] = content;
37-
data['userId'] = userId;
38-
data['objectId'] = objectId;
3932
return data;
4033
}
4134

4235
@override
43-
List<Object> get props => [habitId, time, content, userId, objectId];
36+
List<Object> get props => [habitId, time, content];
4437

4538
HabitRecord copyWith(
4639
{String habitId,
@@ -51,22 +44,18 @@ class HabitRecord extends Equatable {
5144
return HabitRecord(
5245
habitId: habitId ?? this.habitId,
5346
time: time ?? this.time,
54-
content: content ?? this.content,
55-
userId: userId ?? this.userId,
56-
objectId: objectId ?? this.objectId);
47+
content: content ?? this.content);
5748
}
5849
}
5950

6051
// ignore: must_be_immutable
6152
class Habit extends Equatable {
6253
///唯一id uuid v4
63-
final String objectId;
6454
final String id;
6555
final String name;
6656
final String iconPath;
6757
final int mainColor;
6858
final String mark;
69-
final String userId;
7059

7160
///提醒时间 每天 10: 20,eg
7261
///转化为 json String 存储 ["10:20","11:50"]
@@ -101,8 +90,7 @@ class Habit extends Equatable {
10190
final List<HabitRecord> records;
10291

10392
Habit(
104-
{this.objectId,
105-
this.id,
93+
{this.id,
10694
this.name,
10795
this.iconPath,
10896
this.mainColor,
@@ -115,12 +103,11 @@ class Habit extends Equatable {
115103
this.modifyTime,
116104
this.completed,
117105
this.doNum,
118-
this.records,
119-
this.userId});
106+
this.records});
120107

121108
@override
122109
String toString() {
123-
return 'Habit{ objectId: $objectId, id: $id , userId: $userId, name: $name, iconPath: $iconPath, mainColor: '
110+
return 'Habit{id: $id , name: $name, iconPath: $iconPath, mainColor: '
124111
'$mainColor, mark: $mark, remindTimes: $remindTimes, completeTime:'
125112
' $completeTime, completeDays: $completeDays, period: $period, '
126113
'createTime: $createTime, modifyTime: $modifyTime, completed: $completed,'
@@ -145,7 +132,6 @@ class Habit extends Equatable {
145132
}
146133

147134
return Habit(
148-
objectId: json['objectId']?.toString(),
149135
id: json["id"]?.toString(),
150136
name: json["name"]?.toString(),
151137
iconPath: json["iconPath"]?.toString(),
@@ -159,13 +145,11 @@ class Habit extends Equatable {
159145
modifyTime: json["modifyTime"]?.toInt(),
160146
completed: json["completed"]?.toInt() == 1 ? true : false,
161147
doNum: json["doNum"]?.toInt(),
162-
records: records,
163-
userId: json['userId']);
148+
records: records);
164149
}
165150

166151
Map<String, dynamic> toJson() {
167152
final Map<String, dynamic> data = Map<String, dynamic>();
168-
data['objectId'] = objectId;
169153
data["id"] = id;
170154
data["name"] = name;
171155
data["iconPath"] = iconPath;
@@ -195,7 +179,6 @@ class Habit extends Equatable {
195179
data["modifyTime"] = modifyTime;
196180
data["completed"] = completed ? 1 : 0;
197181
data["doNum"] = doNum;
198-
data['userId'] = userId;
199182
return data;
200183
}
201184

@@ -217,7 +200,6 @@ class Habit extends Equatable {
217200

218201
@override
219202
List<Object> get props => [
220-
this.objectId,
221203
this.id,
222204
this.name,
223205
this.iconPath,
@@ -232,7 +214,6 @@ class Habit extends Equatable {
232214
this.completed,
233215
this.doNum,
234216
this.records,
235-
this.userId
236217
];
237218

238219
Habit copyWith(
@@ -253,7 +234,6 @@ class Habit extends Equatable {
253234
List<HabitRecord> records,
254235
String userId}) {
255236
return Habit(
256-
objectId: objectId ?? this.objectId,
257237
id: id ?? this.id,
258238
name: name ?? this.name,
259239
iconPath: iconPath ?? this.iconPath,
@@ -267,7 +247,6 @@ class Habit extends Equatable {
267247
modifyTime: modifyTime ?? this.modifyTime,
268248
completed: completed ?? this.completed,
269249
doNum: doNum ?? this.doNum,
270-
records: records ?? this.records,
271-
userId: userId ?? this.userId);
250+
records: records ?? this.records);
272251
}
273252
}

lib/one_day/habit_check_view.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ class _HabitCheckViewState extends State<HabitCheckView> {
109109
}
110110

111111
HabitRecord record = HabitRecord(
112-
habitId: widget.habitId,
113-
time: checkTime,
114-
content: '',
115-
userId: SessionUtils.sharedInstance().getUserId());
112+
habitId: widget.habitId,
113+
time: checkTime,
114+
content: '',
115+
);
116116

117117
BlocProvider.of<RecordBloc>(context).add(RecordAdd(record));
118118
listKey.currentState.insertItem(0,

0 commit comments

Comments
 (0)