import React from 'react'
import {View, Text, StyleSheet, Pressable, Linking} from 'react-native'

export default function LicenseNotice() {
  return (
    <View style={styles.container}>
      <Text style={styles.title}>Open Source Licenses</Text>

      <View style={styles.section}>
        <Text style={styles.projectName}>Bluesky Social App</Text>
        <Text style={styles.license}>MIT License</Text>
        <Text style={styles.copyright}>Copyright 2023–2025 Bluesky Social PBC</Text>

        <Text style={styles.licenseText}>
          Permission is hereby granted, free of charge, to any person obtaining a copy
          of this software and associated documentation files (the "Software"), to deal
          in the Software without restriction, including without limitation the rights
          to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
          copies of the Software, and to permit persons to whom the Software is
          furnished to do so, subject to the following conditions:
        </Text>

        <Text style={styles.licenseText}>
          The above copyright notice and this permission notice shall be included in all
          copies or substantial portions of the Software.
        </Text>

        <Text style={styles.licenseText}>
          THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
          IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
          FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
          AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
          LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
          OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
          SOFTWARE.
        </Text>

        <Pressable
          onPress={() =>
            Linking.openURL('https://github.com/bluesky-social/social-app')
          }>
          <Text style={styles.link}>View Source Code</Text>
        </Pressable>
      </View>
    </View>
  )
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 16,
  },
  title: {
    fontSize: 24,
    fontWeight: 'bold',
    marginBottom: 20,
    color: '#1d1d1f',
  },
  section: {
    marginBottom: 24,
    padding: 16,
    backgroundColor: '#f5f5f7',
    borderRadius: 8,
  },
  projectName: {
    fontSize: 18,
    fontWeight: '600',
    marginBottom: 8,
    color: '#1d1d1f',
  },
  license: {
    fontSize: 14,
    fontWeight: '500',
    color: '#007aff',
    marginBottom: 4,
  },
  copyright: {
    fontSize: 13,
    color: '#3a3a3c',
    marginBottom: 12,
  },
  licenseText: {
    fontSize: 12,
    lineHeight: 18,
    color: '#3a3a3c',
    marginBottom: 12,
  },
  link: {
    fontSize: 14,
    color: '#007aff',
    textDecorationLine: 'underline',
    marginTop: 8,
  },
})
