@@ -17,40 +17,69 @@ struct WelcomeView: View {
1717 ZStack {
1818
1919 backgroundView
20- . frame ( width: viewModel. size. width, height: viewModel. size. height)
21- . transition ( AnyTransition . opacity)
20+ . frame ( width: viewModel. size. width, height: viewModel. size. height)
21+ . transition ( AnyTransition . opacity)
2222
2323 VStack ( alignment: . leading) {
2424 PagerView ( pageCount: 3 , currentIndex: $currentPage) {
25- firstView
26- secondView
25+ firstView
26+ secondView
2727 }
2828 }
2929 . frame ( width: viewModel. size. width / 2.5 ,
3030 height: viewModel. size. height / 1.5 ,
3131 alignment: . center)
32- . background ( Color . secondary )
33- . cornerRadius ( 4.0 )
34- . offset ( x: 0 ,
35- y: viewModel. isVisible ? ( ( viewModel. size. height / 2 ) - ( ( viewModel. size. height / 1.5 ) / 1.5 ) ) : 10000 )
36- . transition ( AnyTransition . move ( edge: . bottom) )
32+ . background ( Color . BLACK_500 )
33+ . cornerRadius ( 4.0 )
34+ . offset ( x: 0 ,
35+ y: viewModel. isVisible ? ( ( viewModel. size. height / 2 ) - ( ( viewModel. size. height / 1.5 ) / 1.5 ) ) : 10000 )
36+ . transition ( AnyTransition . move ( edge: . bottom) )
3737 }
3838 }
3939
4040 var firstView : some View {
4141 VStack {
42- Spacer ( )
43- Text ( " Test 1 " )
42+ HStack {
43+ Spacer ( )
44+ Text ( " Welcome! " )
45+ . foregroundColor ( . text)
46+ . font ( . title)
47+ Spacer ( )
48+ }
49+ Text ( " Changelog Ver. 1.2 " )
50+ . font ( . subheadline)
51+ . foregroundColor ( . text)
52+ . padding ( EdgeInsets ( top: 16 , leading: 0 , bottom: 16 , trailing: 0 ) )
53+ HStack {
54+ Text ( " - Fix 'non clickable' area \n - Add snippet from StackOverflow via a Chrome Ext. \n - A StackOverflow snippet has a special top bar button to open the dedicated StackOverflow Post " )
55+ . font ( Font . custom ( " CourierNewPSMT " , size: 12 ) )
56+ . foregroundColor ( . text)
57+ Spacer ( )
58+ }
59+ . padding ( EdgeInsets ( top: 16 , leading: 8 , bottom: 16 , trailing: 8 ) )
60+ . background ( Color . BLACK_200)
61+ Text ( " We Need Your Help! " )
62+ . font ( . subheadline)
63+ . foregroundColor ( . text)
64+ . padding ( EdgeInsets ( top: 16 , leading: 0 , bottom: 16 , trailing: 0 ) )
65+ CodeView ( code: . constant( " Snip needs your help to grow! \n \n Want to translate snip into your native language? \n Want to have first-day in our next features? \n \n JOIN US now! " ) , mode: . constant( CodeMode . text. mode ( ) ) )
66+ . frame ( maxWidth: . infinity)
4467 Spacer ( )
4568 HStack {
4669 Spacer ( )
4770 Button ( action: {
48- self . currentPage += 1
71+ self . viewModel . isVisible = false
4972 } ) {
50- Text ( " Next " )
51- . padding ( EdgeInsets ( top: 8 , leading: 20 , bottom: 8 , trailing: 20 ) )
52- . background ( Color . accent)
53- . cornerRadius ( 4 )
73+ Text ( " Close " )
74+ . padding ( EdgeInsets ( top: 8 , leading: 20 , bottom: 8 , trailing: 20 ) )
75+ . background ( Color . transparent)
76+ }
77+ . buttonStyle ( PlainButtonStyle ( ) )
78+ Button ( action: self . viewModel. openSnipWebsite) {
79+ Text ( " JOIN US " )
80+ . padding ( EdgeInsets ( top: 8 , leading: 20 , bottom: 8 , trailing: 20 ) )
81+ . background ( Color . accentDark)
82+ . cornerRadius ( 4 )
5483 }
5584 . buttonStyle ( PlainButtonStyle ( ) )
5685 }
@@ -74,18 +103,23 @@ struct WelcomeView: View {
74103
75104final class WelcomeViewModel : ObservableObject {
76105
77- var isVisible : Bool
106+ @ Binding var isVisible : Bool
78107 var size : CGSize
79108
80- init ( isVisible: Bool , readerSize: CGSize ) {
81- self . isVisible = isVisible
109+ init ( isVisible: Binding < Bool > , readerSize: CGSize ) {
110+ self . _isVisible = isVisible
82111 self . size = readerSize
83112 }
113+
114+ func openSnipWebsite( ) {
115+ guard let url = URL ( string: " https://snip.picta-hub.io " ) else { return }
116+ NSWorkspace . shared. open ( url)
117+ }
84118}
85119
86120struct WelcomeView_Previews : PreviewProvider {
87121 static var previews : some View {
88- WelcomeView ( viewModel: WelcomeViewModel ( isVisible: true ,
122+ WelcomeView ( viewModel: WelcomeViewModel ( isVisible: . constant ( true ) ,
89123 readerSize: CGSize ( width: 300 , height: 400 ) ) )
90124 }
91125}
0 commit comments