Skip to content

Commit

Permalink
タイムラインをCustomScrollViewに変更
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon committed Oct 30, 2023
1 parent 54f7477 commit 863c55c
Show file tree
Hide file tree
Showing 18 changed files with 824 additions and 952 deletions.
6 changes: 6 additions & 0 deletions lib/extensions/note_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ extension NoteExtension on Note {
bool get isEmptyRenote {
return renoteId != null && text == null && files.isEmpty && poll == null;
}

bool get containsSensitiveFile {
return files.any((file) => file.isSensitive) ||
(renote?.files.any((file) => file.isSensitive) ?? false) ||
(reply?.files.any((file) => file.isSensitive) ?? false);
}
}
11 changes: 11 additions & 0 deletions lib/model/timeline_controller_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:flutter/material.dart';

class TimelineControllerState {
const TimelineControllerState({
required this.listKey,
required this.scrollController,
});

final GlobalKey<SliverAnimatedListState> listKey;
final ScrollController scrollController;
}
16 changes: 16 additions & 0 deletions lib/model/timeline_page_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:miria/model/tab_setting.dart';

part 'timeline_page_state.freezed.dart';

@freezed
class TimelinePageState with _$TimelinePageState {
const TimelinePageState._();

const factory TimelinePageState({
required PageController pageController,
required int index,
required TabSetting tabSetting,
}) = _TimelinePageState;
}
189 changes: 189 additions & 0 deletions lib/model/timeline_page_state.freezed.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark

part of 'timeline_page_state.dart';

// **************************************************************************
// FreezedGenerator
// **************************************************************************

T _$identity<T>(T value) => value;

final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');

/// @nodoc
mixin _$TimelinePageState {
PageController get pageController => throw _privateConstructorUsedError;
int get index => throw _privateConstructorUsedError;
TabSetting get tabSetting => throw _privateConstructorUsedError;

@JsonKey(ignore: true)
$TimelinePageStateCopyWith<TimelinePageState> get copyWith =>
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $TimelinePageStateCopyWith<$Res> {
factory $TimelinePageStateCopyWith(
TimelinePageState value, $Res Function(TimelinePageState) then) =
_$TimelinePageStateCopyWithImpl<$Res, TimelinePageState>;
@useResult
$Res call({PageController pageController, int index, TabSetting tabSetting});

$TabSettingCopyWith<$Res> get tabSetting;
}

/// @nodoc
class _$TimelinePageStateCopyWithImpl<$Res, $Val extends TimelinePageState>
implements $TimelinePageStateCopyWith<$Res> {
_$TimelinePageStateCopyWithImpl(this._value, this._then);

// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;

@pragma('vm:prefer-inline')
@override
$Res call({
Object? pageController = null,
Object? index = null,
Object? tabSetting = null,
}) {
return _then(_value.copyWith(
pageController: null == pageController
? _value.pageController
: pageController // ignore: cast_nullable_to_non_nullable
as PageController,
index: null == index
? _value.index
: index // ignore: cast_nullable_to_non_nullable
as int,
tabSetting: null == tabSetting
? _value.tabSetting
: tabSetting // ignore: cast_nullable_to_non_nullable
as TabSetting,
) as $Val);
}

@override
@pragma('vm:prefer-inline')
$TabSettingCopyWith<$Res> get tabSetting {
return $TabSettingCopyWith<$Res>(_value.tabSetting, (value) {
return _then(_value.copyWith(tabSetting: value) as $Val);
});
}
}

/// @nodoc
abstract class _$$_TimelinePageStateCopyWith<$Res>
implements $TimelinePageStateCopyWith<$Res> {
factory _$$_TimelinePageStateCopyWith(_$_TimelinePageState value,
$Res Function(_$_TimelinePageState) then) =
__$$_TimelinePageStateCopyWithImpl<$Res>;
@override
@useResult
$Res call({PageController pageController, int index, TabSetting tabSetting});

@override
$TabSettingCopyWith<$Res> get tabSetting;
}

/// @nodoc
class __$$_TimelinePageStateCopyWithImpl<$Res>
extends _$TimelinePageStateCopyWithImpl<$Res, _$_TimelinePageState>
implements _$$_TimelinePageStateCopyWith<$Res> {
__$$_TimelinePageStateCopyWithImpl(
_$_TimelinePageState _value, $Res Function(_$_TimelinePageState) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
@override
$Res call({
Object? pageController = null,
Object? index = null,
Object? tabSetting = null,
}) {
return _then(_$_TimelinePageState(
pageController: null == pageController
? _value.pageController
: pageController // ignore: cast_nullable_to_non_nullable
as PageController,
index: null == index
? _value.index
: index // ignore: cast_nullable_to_non_nullable
as int,
tabSetting: null == tabSetting
? _value.tabSetting
: tabSetting // ignore: cast_nullable_to_non_nullable
as TabSetting,
));
}
}

/// @nodoc
class _$_TimelinePageState extends _TimelinePageState {
const _$_TimelinePageState(
{required this.pageController,
required this.index,
required this.tabSetting})
: super._();

@override
final PageController pageController;
@override
final int index;
@override
final TabSetting tabSetting;

@override
String toString() {
return 'TimelinePageState(pageController: $pageController, index: $index, tabSetting: $tabSetting)';
}

@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_TimelinePageState &&
(identical(other.pageController, pageController) ||
other.pageController == pageController) &&
(identical(other.index, index) || other.index == index) &&
(identical(other.tabSetting, tabSetting) ||
other.tabSetting == tabSetting));
}

@override
int get hashCode =>
Object.hash(runtimeType, pageController, index, tabSetting);

@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_TimelinePageStateCopyWith<_$_TimelinePageState> get copyWith =>
__$$_TimelinePageStateCopyWithImpl<_$_TimelinePageState>(
this, _$identity);
}

abstract class _TimelinePageState extends TimelinePageState {
const factory _TimelinePageState(
{required final PageController pageController,
required final int index,
required final TabSetting tabSetting}) = _$_TimelinePageState;
const _TimelinePageState._() : super._();

@override
PageController get pageController;
@override
int get index;
@override
TabSetting get tabSetting;
@override
@JsonKey(ignore: true)
_$$_TimelinePageStateCopyWith<_$_TimelinePageState> get copyWith =>
throw _privateConstructorUsedError;
}
14 changes: 14 additions & 0 deletions lib/providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:miria/model/account.dart';
import 'package:miria/model/acct.dart';
import 'package:miria/model/tab_setting.dart';
import 'package:miria/model/timeline_controller_state.dart';
import 'package:miria/model/timeline_page_state.dart';
import 'package:miria/model/timeline_state.dart';
import 'package:miria/repository/account_repository.dart';
import 'package:miria/repository/account_settings_repository.dart';
Expand All @@ -20,6 +22,8 @@ import 'package:miria/repository/timeline_repository.dart';
import 'package:miria/state_notifier/common/misskey_server_list_notifier.dart';
import 'package:miria/state_notifier/note_create_page/note_create_state_notifier.dart';
import 'package:miria/state_notifier/photo_edit_page/photo_edit_state_notifier.dart';
import 'package:miria/state_notifier/timeline_page/timeline_controller.dart';
import 'package:miria/state_notifier/timeline_page/timeline_page_controller.dart';
import 'package:misskey_dart/misskey_dart.dart';

final dioProvider = Provider((ref) => Dio());
Expand All @@ -38,6 +42,16 @@ final timelineRepositoryProvider =
TimelineRepository.new,
);

final timelineControllerProvider = NotifierProvider.autoDispose
.family<TimelineController, TimelineControllerState, TabSetting>(
TimelineController.new,
);

final timelinePageControllerProvider =
NotifierProvider.autoDispose<TimelinePageController, TimelinePageState>(
TimelinePageController.new,
);

final mainStreamRepositoryProvider =
ChangeNotifierProvider.family<MainStreamRepository, Account>(
(ref, account) => MainStreamRepository(
Expand Down
23 changes: 6 additions & 17 deletions lib/router/app_router.gr.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 863c55c

Please sign in to comment.