77 lines
2.0 KiB
Dart
77 lines
2.0 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:path/path.dart' as p;
|
|
|
|
class Sheet {
|
|
final String uuid;
|
|
final String name;
|
|
final String composerUuid;
|
|
final DateTime releaseDate;
|
|
final String file;
|
|
final String fileHash;
|
|
final bool wasUploaded;
|
|
final int uploaderId;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
final DateTime lastOpened;
|
|
final List<String> tags;
|
|
final String informationText;
|
|
|
|
Sheet({
|
|
required this.uuid,
|
|
required this.name,
|
|
required this.composerUuid,
|
|
required this.releaseDate,
|
|
required this.file,
|
|
required this.fileHash,
|
|
required this.wasUploaded,
|
|
required this.uploaderId,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
required this.lastOpened,
|
|
required this.tags,
|
|
required this.informationText,
|
|
});
|
|
|
|
// Factory constructor for creating a Sheet from JSON
|
|
factory Sheet.fromJson(Map<String, dynamic> json) {
|
|
return Sheet(
|
|
uuid: json['uuid'],
|
|
name: json['sheet_name'],
|
|
composerUuid: json['composer_uuid'],
|
|
releaseDate: DateTime.parse(json['release_date']),
|
|
file: json['file'],
|
|
fileHash: json['file_hash'],
|
|
wasUploaded: json['was_uploaded'],
|
|
uploaderId: json['uploader_id'],
|
|
createdAt: DateTime.parse(json['created_at']),
|
|
updatedAt: DateTime.parse(json['updated_at']),
|
|
lastOpened: DateTime.parse(json['last_opened']),
|
|
tags: List<String>.from(json['tags']),
|
|
informationText: json['information_text'],
|
|
);
|
|
}
|
|
}
|
|
|
|
class SheetsWidget extends StatelessWidget {
|
|
final List<Sheet> sheets;
|
|
final ValueSetter<Sheet> callback;
|
|
|
|
const SheetsWidget({super.key, required this.sheets, required this.callback});
|
|
|
|
@override
|
|
Widget build(context) {
|
|
return ListView.builder(
|
|
itemCount: sheets.length,
|
|
itemBuilder: (context, index) {
|
|
var sheet = sheets[index];
|
|
return ListTile(
|
|
title: Text(sheet.name),
|
|
subtitle: Text(sheet.uuid),
|
|
onTap: () => callback(sheet),
|
|
);
|
|
});
|
|
}
|
|
}
|