Skip to content

Commit

Permalink
h
Browse files Browse the repository at this point in the history
  • Loading branch information
Notsfsssf committed Jul 1, 2020
1 parent fff569a commit dcb1a02
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 113 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies

Large diffs are not rendered by default.

Binary file added assets/images/h.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 60 additions & 21 deletions lib/component/illust_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:pixez/bloc/bloc.dart';
import 'package:pixez/component/star_icon.dart';
import 'package:pixez/main.dart';
Expand Down Expand Up @@ -55,33 +56,68 @@ class _IllustCardState extends State<IllustCard> {

@override
Widget build(BuildContext context) {
return BlocBuilder<MuteBloc, MuteState>(builder: (context, snapshot) {
if (snapshot is DataMuteState) {
for (var i in snapshot.banIllustIds) {
if (i.illustId == widget._illusts.id.toString())
return Visibility(
visible: false,
child: Container(),
);
}
for (var j in snapshot.banUserIds) {
if (j.userId == widget._illusts.user.id.toString())
return Visibility(
visible: false,
child: Container(),
return Observer(builder: (_) {
if (userSetting.hIsNotAllow)
for (int i = 0; i < widget._illusts.tags.length; i++) {
if (widget._illusts.tags[i].name.startsWith('R-18'))
return InkWell(
onTap: () => {
Navigator.of(context, rootNavigator: true)
.push(MaterialPageRoute(builder: (_) {
if (widget.illustList != null) {
return PictureListPage(
illusts: widget.illustList,
nowPosition: widget.illustList.indexOf(widget._illusts),
);
}
return PicturePage(
widget._illusts,
widget._illusts.id,
);
}))
},
onLongPress: () {
saveStore.saveImage(widget._illusts);
},
child: Card(
margin: EdgeInsets.all(8.0),
elevation: 8.0,
clipBehavior: Clip.antiAlias,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(8.0))),
child: Image.asset('assets/h.jpg'),
),
);
}
for (var t in snapshot.banTags) {
for (var f in widget._illusts.tags) {
if (f.name == t.name)

return BlocBuilder<MuteBloc, MuteState>(builder: (context, snapshot) {
if (snapshot is DataMuteState) {
for (var i in snapshot.banIllustIds) {
if (i.illustId == widget._illusts.id.toString())
return Visibility(
visible: false,
child: Container(),
);
}
for (var j in snapshot.banUserIds) {
if (j.userId == widget._illusts.user.id.toString())
return Visibility(
visible: false,
child: Container(),
);
}
for (var t in snapshot.banTags) {
for (var f in widget._illusts.tags) {
if (f.name == t.name)
return Visibility(
visible: false,
child: Container(),
);
}
}
}
}
return buildInkWell(context);
return buildInkWell(context);
});
});
}

Expand Down Expand Up @@ -173,7 +209,7 @@ class _IllustCardState extends State<IllustCard> {
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.only(
left: 8.0, right: 34.0, top: 4,bottom: 4),
left: 8.0, right: 34.0, top: 4, bottom: 4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expand Down Expand Up @@ -219,7 +255,10 @@ class _IllustCardState extends State<IllustCard> {
),
),
),
Align(child: _buildVisibility(),alignment: Alignment.topRight,)
Align(
child: _buildVisibility(),
alignment: Alignment.topRight,
)
],
),
),
Expand Down
183 changes: 94 additions & 89 deletions lib/page/hello/recom/recom_spotlight_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_easyrefresh/bezier_circle_header.dart';
import 'package:flutter_easyrefresh/bezier_hour_glass_header.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
Expand Down Expand Up @@ -61,57 +63,71 @@ class _RecomSpolightPageState extends State<RecomSpolightPage>
Widget build(BuildContext context) {
super.build(context);
return Observer(builder: (_) {
return SafeArea(
child: EasyRefresh(
controller: _easyRefreshController,
enableControlFinishLoad: true,
enableControlFinishRefresh: true,
firstRefresh: true,
onRefresh: () {
return fetchT();
},
onLoad: () {
return _lightingStore.fetchNext();
},
child: _lightingStore.illusts.isNotEmpty
? StaggeredGridView.countBuilder(
crossAxisCount: 2,
padding: EdgeInsets.all(0.0),
staggeredTileBuilder: (int index) {
if (index < 3)
return StaggeredTile.fit(2);
else {
double screanWidth = MediaQuery.of(context).size.width;
double itemWidth = (screanWidth / 2.0) - 32.0;
double radio = _lightingStore.illusts[index - 3].height
.toDouble() /
_lightingStore.illusts[index - 3].width.toDouble();
double mainAxisExtent;
if (radio > 2)
mainAxisExtent = itemWidth;
else
mainAxisExtent = itemWidth * radio;
return StaggeredTile.extent(1, mainAxisExtent + 80.0);
}
},
itemCount: _lightingStore.illusts.length + 3,
itemBuilder: (BuildContext context, int index) {
if (index == 0) return _buildFirstRow(context);
if (index == 1) return _buildSpotlightContainer();
if (index == 2) return _buildSecondRow(context);
if (index >= 3)
return IllustCard(
_lightingStore.illusts[index - 3],
illustList: _lightingStore.illusts,
);
return buildEasyRefresh(context);
});
}

return Container();
},
)
: Container(),
Widget buildEasyRefresh(BuildContext context) {
return EasyRefresh(
controller: _easyRefreshController,
enableControlFinishLoad: true,
enableControlFinishRefresh: true,
header:
BezierCircleHeader(backgroundColor: Theme.of(context).accentColor),
firstRefresh: true,
onRefresh: () {
return fetchT();
},
firstRefreshWidget: Container(
child: Center(
child: CircularProgressIndicator(),
),
);
});
),
onLoad: () {
return _lightingStore.fetchNext();
},
child: _lightingStore.illusts.isNotEmpty
? StaggeredGridView.countBuilder(
crossAxisCount: 2,
padding: EdgeInsets.all(0.0),
staggeredTileBuilder: (int index) {
if (index < 3)
return StaggeredTile.fit(2);
else {
double screanWidth = MediaQuery.of(context).size.width;
double itemWidth = (screanWidth / 2.0) - 32.0;
double radio =
_lightingStore.illusts[index - 3].height.toDouble() /
_lightingStore.illusts[index - 3].width.toDouble();
double mainAxisExtent;
if (radio > 2)
mainAxisExtent = itemWidth;
else
mainAxisExtent = itemWidth * radio;
return StaggeredTile.extent(1, mainAxisExtent + 80.0);
}
},
itemCount: _lightingStore.illusts.length + 3,
itemBuilder: (BuildContext context, int index) {
if (index == 0)
return AppBar(
elevation: 0.0,
backgroundColor: Colors.transparent,
title: _buildFirstRow(context),
);
if (index == 1) return _buildSpotlightContainer();
if (index == 2) return _buildSecondRow(context);
if (index >= 3)
return IllustCard(
_lightingStore.illusts[index - 3],
illustList: _lightingStore.illusts,
);

return Container();
},
)
: Container(),
);
}

Container _buildSpotlightContainer() {
Expand All @@ -134,48 +150,37 @@ class _RecomSpolightPageState extends State<RecomSpolightPage>
}

Widget _buildFirstRow(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
AppBar(
automaticallyImplyLeading: false,
titleSpacing: 0.0,
title: Padding(
padding: const EdgeInsets.only(top: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
child: Padding(
child: Text(
I18n.of(context).Spotlight,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 30.0,
color: Theme.of(context).textTheme.headline6.color),
),
padding: EdgeInsets.only(left: 20.0, bottom: 10.0),
),
),
Padding(
child: FlatButton(
child: Text(I18n.of(context).More),
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (BuildContext context) {
return SpotLightPage();
}));
},
),
padding: EdgeInsets.all(8.0),
)
],
return Padding(
padding: const EdgeInsets.only(top: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
child: Padding(
child: Text(
I18n.of(context).Spotlight,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 30.0,
color: Theme.of(context).textTheme.headline6.color),
),
padding: EdgeInsets.only(left: 20.0, bottom: 10.0),
),
),
elevation: 0.0,
backgroundColor: Colors.transparent,
),
],
Padding(
child: FlatButton(
child: Text(I18n.of(context).More),
onPressed: () {
Navigator.of(context)
.push(MaterialPageRoute(builder: (BuildContext context) {
return SpotLightPage();
}));
},
),
padding: EdgeInsets.all(8.0),
)
],
),
);
}

Expand Down
15 changes: 15 additions & 0 deletions lib/page/hello/setting/setting_quality_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,21 @@ class _SettingQualityPageState extends State<SettingQualityPage>
}),
);
}),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Observer(builder: (_) {
return Card(
child: SwitchListTile(
value: userSetting.hIsNotAllow,
title: Text(userSetting.hIsNotAllow?'H是不行的!':'H是可以的!(ˉ﹃ˉ)'),
onChanged: (value) async {

userSetting.setHIsNotAllow(value);

}),
);
}),
)
]),
),
Expand Down
11 changes: 9 additions & 2 deletions lib/store/user_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ abstract class _UserSettingBase with Store {
@observable
bool singleFolder = false;
@observable
bool hIsNotAllow = false;
@observable
String path = "";
@observable
String format = "";
Expand All @@ -59,6 +61,7 @@ abstract class _UserSettingBase with Store {
path = prefs.getString("store_path");
displayMode = prefs.getInt('display_mode');
disableBypassSni = prefs.getBool('disable_bypass_sni') ?? false;
hIsNotAllow = prefs.getBool('h_is_not_allow') ?? false;
if (Platform.isAndroid) {
if (path == null)
path = (await platform.invokeMethod('get_path')) as String;
Expand All @@ -68,14 +71,18 @@ abstract class _UserSettingBase with Store {
await FlutterDisplayMode.setMode(modeList[displayMode]);
}
}
debugPrint("path==========${path}");
languageNum = prefs.getInt(LANGUAGE_NUM_KEY) ?? 0;
format = prefs.getString(SAVE_FORMAT_KEY) ?? intialFormat;
debugPrint("language:${languageNum}");
ApiClient.Accept_Language = languageList[languageNum];
I18n.load(I18n.delegate.supportedLocales[languageNum]);
}

@action
setHIsNotAllow(bool value) async {
await prefs.setBool('h_is_not_allow', value);
hIsNotAllow = value;
}

@action
setDisableBypassSni(bool value) async {
await prefs.setBool('disable_bypass_sni', value);
Expand Down
Loading

0 comments on commit dcb1a02

Please sign in to comment.