Skip to content

Commit

Permalink
✨ Link to welook.io when no moments in event
Browse files Browse the repository at this point in the history
  • Loading branch information
RockerFlower authored and RockerFlower committed Aug 30, 2022
1 parent 853b705 commit 0cc51a1
Show file tree
Hide file tree
Showing 2 changed files with 160 additions and 95 deletions.
4 changes: 4 additions & 0 deletions lib/ui/pages/event/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ class EventDetailController extends BaseController {
refreshController.loadComplete();
}

void launchWelook(int eventID) {
launchURL('https://welook.io/moments/$eventID');
}

/// Moments ---------------------------------------------------------------End
updateID(int id) {
Expand Down
251 changes: 156 additions & 95 deletions lib/ui/pages/event/views/page.moments.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:poapin/common/translations/strings.dart';
import 'package:poapin/data/models/moment.dart';
import 'package:poapin/res/colors.dart';
import 'package:poapin/ui/components/loading.dart';
import 'package:poapin/ui/pages/event/controller.dart';
import 'package:poapin/ui/pages/home/controller.dart';
import 'package:poapin/ui/pages/moment/page.dart';
import 'package:pull_to_refresh_flutter3/pull_to_refresh_flutter3.dart';

Expand Down Expand Up @@ -61,107 +64,165 @@ class MomentsInEventPage extends StatelessWidget {
right: 0,
bottom: 0),
child: GetBuilder<EventDetailController>(
builder: (c) => SmartRefresher(
enablePullDown: false,
enablePullUp: true,
footer: CustomFooter(
builder: (BuildContext context, LoadStatus? mode) {
Widget body;
if (mode == LoadStatus.idle) {
body = Text("pull up to load",
style: TextStyle(color: Colors.grey[400]));
} else if (mode == LoadStatus.noMore) {
body = Text("All moments loaded",
style: TextStyle(color: Colors.grey[400]));
} else if (mode == LoadStatus.loading) {
body = const CupertinoActivityIndicator();
} else if (mode == LoadStatus.failed) {
body = Text("Load Failed! Tap to retry!",
style: TextStyle(color: Colors.grey[400]));
} else if (mode == LoadStatus.canLoading) {
body = Text("release to load more",
style: TextStyle(color: Colors.grey[400]));
} else {
body = Text("No more Data",
style: TextStyle(color: Colors.grey[400]));
}
return SizedBox(
height: 55.0,
child: Center(child: body),
);
},
),
controller: c.refreshController,
onLoading: c.onLoading,
child: CustomScrollView(
slivers: [
SliverToBoxAdapter(
child: Container(
height: 256 + 32,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
stops: const [0.0, 1.0],
colors: [PColor.background, Colors.white])),
),
),
c.isLoadingAllMoments
? const SliverToBoxAdapter(
child: Center(
child: LoadingAnimation(),
))
: SliverPadding(
padding: EdgeInsets.only(
left: 16 + safePaddingLeft,
right: 16 + safePaddingRight,
top: 12,
bottom: 12,
),
sliver: SliverMasonryGrid.count(
crossAxisCount: crossAxisCount,
mainAxisSpacing: 8,
crossAxisSpacing: 8,
childCount: c.moments.length,
itemBuilder: (context, index) {
if (c.isLoadingAllMoments && index == 1) {
return const SizedBox(
height: 128,
child: Align(
child: SizedBox(
width: 16,
height: 16,
child:
CircularProgressIndicator(strokeWidth: 1),
),
builder: (c) => c.isLoadingAllMoments
? ListView(
children: const [
SizedBox(height: 256 + 32),
LoadingAnimation(),
],
)
: c.momentCount == 0
? ListView(
children: [
const SizedBox(height: 256 + 32),
Container(
padding: const EdgeInsets.symmetric(horizontal: 32),
constraints: const BoxConstraints(maxWidth: 400),
child: Column(
children: [
Container(
padding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 0),
width: double.infinity,
child: Image.asset(
'icons/ic_moments.png',
package: 'web3_icons',
height: 18,
),
);
}
return Card(
elevation: 8,
shadowColor: Colors.blueGrey.withOpacity(0.2),
clipBehavior: Clip.antiAlias,
shape: ContinuousRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
child: SizedBox(
width: 100,
child: Column(
children: [
_buildPreviewImage(
c.moments[index],
c.getPreviewImageURL(c.moments[index]),
context),
],
const SizedBox(height: 32),
Text(
strMomentsDesc,
style: GoogleFonts.roboto(
fontSize: 16,
color: Colors.black54,
),
),
const SizedBox(height: 16),
RawMaterialButton(
onPressed: () {
c.launchWelook(c.eventID);
},
shape: ContinuousRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
fillColor: PColor.welook,
elevation: 0,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 12),
child: Text(
strUploadMoments,
style: GoogleFonts.roboto(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.white,
),
),
),
),
);
},
],
),
),
],
)
: SmartRefresher(
enablePullDown: false,
enablePullUp: true,
footer: CustomFooter(
builder: (BuildContext context, LoadStatus? mode) {
Widget body;
if (mode == LoadStatus.idle) {
body = Text("pull up to load",
style: TextStyle(color: Colors.grey[400]));
} else if (mode == LoadStatus.noMore) {
body = Text("All moments loaded",
style: TextStyle(color: Colors.grey[400]));
} else if (mode == LoadStatus.loading) {
body = const CupertinoActivityIndicator();
} else if (mode == LoadStatus.failed) {
body = Text("Load Failed! Tap to retry!",
style: TextStyle(color: Colors.grey[400]));
} else if (mode == LoadStatus.canLoading) {
body = Text("release to load more",
style: TextStyle(color: Colors.grey[400]));
} else {
body = Text("No more Data",
style: TextStyle(color: Colors.grey[400]));
}
return SizedBox(
height: 55.0,
child: Center(child: body),
);
},
),
],
),
),
controller: c.refreshController,
onLoading: c.onLoading,
child: CustomScrollView(
slivers: [
SliverToBoxAdapter(
child: Container(
height: 256 + 32,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
stops: const [0.0, 1.0],
colors: [PColor.background, Colors.white])),
),
),
SliverPadding(
padding: EdgeInsets.only(
left: 16 + safePaddingLeft,
right: 16 + safePaddingRight,
top: 12,
bottom: 12,
),
sliver: SliverMasonryGrid.count(
crossAxisCount: crossAxisCount,
mainAxisSpacing: 8,
crossAxisSpacing: 8,
childCount: c.moments.length,
itemBuilder: (context, index) {
if (c.isLoadingAllMoments && index == 1) {
return const SizedBox(
height: 128,
child: Align(
child: SizedBox(
width: 16,
height: 16,
child: CircularProgressIndicator(
strokeWidth: 1),
),
),
);
}
return Card(
elevation: 8,
shadowColor: Colors.blueGrey.withOpacity(0.2),
clipBehavior: Clip.antiAlias,
shape: ContinuousRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
child: SizedBox(
width: 100,
child: Column(
children: [
_buildPreviewImage(
c.moments[index],
c.getPreviewImageURL(
c.moments[index]),
context),
],
),
),
);
},
),
),
],
),
),
),
);
}
Expand Down

0 comments on commit 0cc51a1

Please sign in to comment.