mirror of
https://github.com/Livinglist/Hacki.git
synced 2025-08-06 18:24:42 +08:00

* improved story screen scrolling. * bumped version. * shrink instead of return on tapping back button. #42 * allowed users to view other user's profile. #45 * bumped version. * added back underline to links. * fixed overlow of popup menu,
47 lines
1.1 KiB
Dart
47 lines
1.1 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
class User {
|
|
User({
|
|
required this.about,
|
|
required this.created,
|
|
required this.delay,
|
|
required this.id,
|
|
required this.karma,
|
|
});
|
|
|
|
User.empty()
|
|
: about = '',
|
|
created = 0,
|
|
delay = 0,
|
|
id = '',
|
|
karma = 0;
|
|
|
|
User.fromJson(Map<String, dynamic> json)
|
|
: about = json['about'] as String? ?? '',
|
|
created = json['created'] as int? ?? 0,
|
|
delay = json['delay'] as int? ?? 0,
|
|
id = json['id'] as String? ?? '',
|
|
karma = json['karma'] as int? ?? 0;
|
|
|
|
final String about;
|
|
final int created;
|
|
final int delay;
|
|
final String id;
|
|
final int karma;
|
|
|
|
static final DateFormat _dateTimeFormatter = DateFormat.yMMMd();
|
|
|
|
String get description {
|
|
return '''$karma karma, created on ${_dateTimeFormatter.format(DateTime.fromMillisecondsSinceEpoch(created * 1000))}''';
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
final String prettyString =
|
|
const JsonEncoder.withIndent(' ').convert(this);
|
|
return 'User $prettyString';
|
|
}
|
|
}
|