Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ethan
/
appframe
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 43503500
authored
2025-10-30 09:53:10 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
增加开屏广告界面和逻辑,更改抽屉设置界面的颜色
1 parent
e32333b3
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
121 additions
and
2 deletions
lib/bloc/adv_cubit.dart
lib/config/routes.dart
lib/ui/pages/adv_page.dart
lib/ui/pages/web_page.dart
lib/bloc/adv_cubit.dart
0 → 100644
View file @
4350350
import
'dart:async'
;
import
'package:appframe/config/routes.dart'
;
import
'package:equatable/equatable.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
class
AdvState
extends
Equatable
{
final
int
countdown
;
const
AdvState
({
this
.
countdown
=
5
});
AdvState
copyWith
({
int
?
countdown
,
})
{
return
AdvState
(
countdown:
countdown
??
this
.
countdown
,
);
}
@override
List
<
Object
?>
get
props
=>
[
countdown
];
}
class
AdvCubit
extends
Cubit
<
AdvState
>
{
Timer
?
_timer
;
AdvCubit
()
:
super
(
AdvState
())
{
_startCountdown
();
}
void
_startCountdown
()
{
var
count
=
state
.
countdown
;
_timer
=
Timer
.
periodic
(
Duration
(
seconds:
1
),
(
timer
)
{
count
--;
if
(
count
<=
0
)
{
_timer
?.
cancel
();
router
.
go
(
'/web'
);
}
else
{
emit
(
state
.
copyWith
(
countdown:
count
));
}
});
}
@override
Future
<
void
>
close
()
{
try
{
_timer
?.
cancel
();
}
catch
(
e
)
{
print
(
e
);
}
return
super
.
close
();
}
}
lib/config/routes.dart
View file @
4350350
import
'package:appframe/ui/pages/adv_page.dart'
;
import
'package:appframe/ui/pages/link_page.dart'
;
import
'package:appframe/ui/pages/link_page.dart'
;
import
'package:appframe/ui/pages/login_main_page.dart'
;
import
'package:appframe/ui/pages/login_main_page.dart'
;
import
'package:appframe/ui/pages/login_phone_page.dart'
;
import
'package:appframe/ui/pages/login_phone_page.dart'
;
...
@@ -8,7 +9,7 @@ import 'package:flutter/material.dart';
...
@@ -8,7 +9,7 @@ import 'package:flutter/material.dart';
import
'package:go_router/go_router.dart'
;
import
'package:go_router/go_router.dart'
;
final
GoRouter
router
=
GoRouter
(
final
GoRouter
router
=
GoRouter
(
initialLocation:
'/
web
'
,
initialLocation:
'/
adv
'
,
routes:
<
RouteBase
>[
routes:
<
RouteBase
>[
GoRoute
(
GoRoute
(
path:
'/web'
,
path:
'/web'
,
...
@@ -46,5 +47,11 @@ final GoRouter router = GoRouter(
...
@@ -46,5 +47,11 @@ final GoRouter router = GoRouter(
return
const
LoginPhonePage
();
return
const
LoginPhonePage
();
},
},
),
),
GoRoute
(
path:
'/adv'
,
builder:
(
BuildContext
context
,
GoRouterState
state
)
{
return
const
AdvPage
();
},
),
],
],
);
);
lib/ui/pages/adv_page.dart
0 → 100644
View file @
4350350
import
'package:appframe/bloc/adv_cubit.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
class
AdvPage
extends
StatelessWidget
{
const
AdvPage
({
super
.
key
});
@override
Widget
build
(
BuildContext
context
)
{
return
BlocProvider
(
create:
(
context
)
=>
AdvCubit
(),
child:
BlocConsumer
<
AdvCubit
,
AdvState
>(
builder:
(
context
,
state
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
''
),
),
// body: Center(
// child: Text(
// '${state.countdown}',
// style: TextStyle(fontSize: 50),
// ),
// ),
body:
Stack
(
children:
[
Center
(
child:
GestureDetector
(
onTap:
()
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
'点击了开屏广告'
)));
},
child:
Text
(
'开屏广告'
,
style:
TextStyle
(
fontSize:
50
),
)),
),
Positioned
(
bottom:
30
,
right:
30
,
child:
Container
(
width:
36
,
height:
36
,
decoration:
BoxDecoration
(
shape:
BoxShape
.
circle
,
color:
Color
(
0xFF7691FA
),
),
child:
Center
(
child:
Text
(
'
${state.countdown}
'
,
style:
TextStyle
(
fontSize:
20
,
color:
Colors
.
white
),
),
),
),
),
]),
);
},
listener:
(
context
,
state
)
{}),
);
}
}
lib/ui/pages/web_page.dart
View file @
4350350
...
@@ -139,7 +139,7 @@ class WebPage extends StatelessWidget {
...
@@ -139,7 +139,7 @@ class WebPage extends StatelessWidget {
// fontSize: 24,
// fontSize: 24,
// ))),
// ))),
ListTile
(
ListTile
(
tileColor:
Theme
.
of
(
ctx
).
colorScheme
.
primary
,
tileColor:
Color
(
0xFF7691FA
)
,
title:
Text
(
'设置'
,
title:
Text
(
'设置'
,
style:
TextStyle
(
style:
TextStyle
(
color:
Theme
.
of
(
ctx
).
colorScheme
.
onPrimary
,
color:
Theme
.
of
(
ctx
).
colorScheme
.
onPrimary
,
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment